Skip to content

Commit

Permalink
feat(signal2): update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd committed Jun 1, 2023
1 parent 7ff1b96 commit c6b40de
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 47 deletions.
3 changes: 2 additions & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
<li><a href="./logger/">Logger</a></li>
<li><a href="./fetch/">Fetch</a></li>
<li><a href="./signal/">Signal</a></li>
<li><a href="./signal2/">Signal 2</a></li>
<li><a href="./signal2/simple/">Signal simple</a></li>
<li><a href="./signal2/multithread-context/">Signal multithread</a></li>
<li><a href="./router/">Router</a></li>
<li><a href="./font/">Font</a></li>
<li><a href="./math/">Math</a></li>
Expand Down
19 changes: 0 additions & 19 deletions demo/signal2/event/index.ts

This file was deleted.

21 changes: 0 additions & 21 deletions demo/signal2/index.html

This file was deleted.

4 changes: 2 additions & 2 deletions demo/signal2/multithread-context/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {AlwatrMultithreadContext} from '@alwatr/signal2';
import {AlwatrMultithreadContextSignal} from '@alwatr/signal2';

import './main.js';

const worker = new Worker('./worker.js', {type: 'module'});
AlwatrMultithreadContext.setupChannel(worker);
AlwatrMultithreadContextSignal.setupChannel(worker);
4 changes: 2 additions & 2 deletions demo/signal2/multithread-context/share-context.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {AlwatrMultithreadContext} from '@alwatr/signal2';
import {AlwatrMultithreadContextSignal} from '@alwatr/signal2';

import type {Stringifyable} from '@alwatr/type';

type Message = {
type: string;
payload: Stringifyable
}
export const messageContext = new AlwatrMultithreadContext<Message>('demo.message');
export const messageContext = new AlwatrMultithreadContextSignal<Message>('demo.message');
4 changes: 2 additions & 2 deletions demo/signal2/multithread-context/worker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {createLogger} from '@alwatr/logger';
import {AlwatrMultithreadContext} from '@alwatr/signal2';
import {AlwatrMultithreadContextSignal} from '@alwatr/signal2';

AlwatrMultithreadContext.setupChannel();
AlwatrMultithreadContextSignal.setupChannel();

import {messageContext} from './share-context.js';

Expand Down
File renamed without changes.
17 changes: 17 additions & 0 deletions demo/signal2/simple/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {AlwatrEventSignal, AlwatrSimpleSignal} from '@alwatr/signal2';

const clickEvent = new AlwatrSimpleSignal('myClick');

document.getElementById('myButton')?.addEventListener('click', () => clickEvent.dispatch());

clickEvent.subscribe(() => {
console.log('subscribe: a new signal received ');
});

const clickEvent2 = new AlwatrEventSignal('myClick2');

document.getElementById('myButton2')?.addEventListener('click', () => clickEvent2.dispatch({clickedBy: 'MHF'}));

clickEvent2.subscribe((detail) => {
console.log('subscribe: a new signal received ', detail);
});

0 comments on commit c6b40de

Please sign in to comment.