realar/readme/third

node v14.17.6
version: master
endpointsharetweet
const { value, signal } = require('realar'); const store = value(0) const add = store.updater((state, num) => state + num) const inc = store.updater(state => state + 1) const addendum = value('0') const sum = signal() .map(() => +addendum.val) .filter() .to(add); // Subscribe to store updates store.to(state => console.log(`state ${state}`)); inc(); // in console: state 1 addendum('9') sum(); // in console: state 10 addendum('Hi'); sum(); // nothing happens, because the signal has been stopped. It no possible to convert "Hi" string to a number.
Loading…

no comments

    sign in to comment