Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.


[effector] storages and events

node v8.17.0
version: 17.7.0
const {createStore, createEvent} = require('effector') const turnOn = createEvent() const turnOff = createEvent() const status = createStore('offline') .on(turnOn, () => 'online') .on(turnOff, () => 'offline') status.watch(newStatus => { console.log(`status changed: ${newStatus}`) }) turnOff() turnOn() turnOff() turnOff() // Will not trigger watch function because nothing has changed /* result: status changed: offline status changed: online status changed: offline */

no comments

    sign in to comment