Last active
March 18, 2017 05:30
-
-
Save vbkmr/7a6f632522373e9fb721f3777112d06a to your computer and use it in GitHub Desktop.
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
>main.js //to be invoked onLoad() | |
const store_ = new Store(); | |
... | |
>store.js | |
constructor(){ | |
this.state_ = {}; | |
this.stateSubscriber_ = []; | |
} | |
set state(key, value){ | |
//change state by key | |
this.state[key] = value; | |
// invoke onStateChange | |
for each(sub in this.stateSubscriber_) | |
sub.onStateChange_(key); | |
} | |
>indexPage.js | |
onStateChange_(udatedStateKey){ | |
//update UI based on changes state | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment