mirror of
https://github.com/jaandrle/deka-dom-el
synced 2024-11-25 01:39:37 +01:00
Jan Andrle
cd62782c7b
* ⚡ refact docs to make editing (now renaming observables to signal) easier * ⚡ ⚡ use signal(s) term isntead of observable(s) * ⚡ 🔤 version + typo * 🐛 customElement example (0→S) * 📺 version in package-lock.json
17 lines
523 B
JavaScript
17 lines
523 B
JavaScript
import { S } from "deka-dom-el/signals";
|
|
const signal= S(0);
|
|
// computation pattern
|
|
const double= S(()=> 2*signal());
|
|
|
|
const ac= new AbortController();
|
|
S.on(signal, v=> console.log("signal", v), { signal: ac.signal });
|
|
S.on(double, v=> console.log("double", v), { signal: ac.signal });
|
|
|
|
signal(signal()+1);
|
|
const interval= 5 * 1000;
|
|
const id= setInterval(()=> signal(signal()+1), interval);
|
|
ac.signal.addEventListener("abort",
|
|
()=> setTimeout(()=> clearInterval(id), 2*interval));
|
|
|
|
setTimeout(()=> ac.abort(), 3*interval)
|