Last active
July 23, 2020 15:29
-
-
Save orYoffe/25fe1747deb524737bb301d7d2c63ded to your computer and use it in GitHub Desktop.
jstates simple example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createState = require("jstates"); | |
const myState = createState({ counter: 0 }); | |
function onUpdate(state) { | |
console.log("onUpdate: counter =", state.counter); | |
} | |
myState.subscribe(onUpdate); | |
myState.setState(state => ({ counter: ++state.counter })); | |
// => onUpdate: counter = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment