1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2024-11-25 09:49:36 +01:00
deka-dom-el/docs_src/components/examples/signals/actions-demo.js

19 lines
406 B
JavaScript
Raw Normal View History

import { S } from "deka-dom-el/signals";
const signal= S(0, {
2023-11-29 18:25:21 +01:00
increaseOnlyOdd(add){
console.info(add);
if(add%2 === 0) return this.stopPropagation();
this.value+= add;
}
});
S.on(signal, console.log);
2023-11-29 18:25:21 +01:00
const oninterval= ()=>
S.action(signal, "increaseOnlyOdd", Math.floor(Math.random()*100));
2023-11-29 18:25:21 +01:00
const interval= 5*1000;
setTimeout(
clearInterval,
10*interval,
setInterval(oninterval, interval)
);