Created
December 13, 2016 15:39
-
-
Save thomhos/9effa150617428d17383b3173176d5ff to your computer and use it in GitHub Desktop.
pull-based state change propagation
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
/* | |
* State change mechanism | |
*/ | |
let update | |
const onStateChange = _update => { | |
update = _update | |
} | |
const setState = newState => { | |
state = newState | |
update() | |
} | |
/* | |
* Change is propagated to the view when state has changed | |
*/ | |
onStateChange(() => { | |
view = render(state) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment