Skip to content

Instantly share code, notes, and snippets.

@vbkmr
Last active March 18, 2017 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vbkmr/7a6f632522373e9fb721f3777112d06a to your computer and use it in GitHub Desktop.
Save vbkmr/7a6f632522373e9fb721f3777112d06a to your computer and use it in GitHub Desktop.
>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