March 2018
Intermediate to advanced
364 pages
8h 21m
English
To tell the view that something has happened and act on it, three things need to happen:
Starting with the store, we need to build it out so that you can register as a listener to its events. We therefore add the addListener() method:
// store-with-pubsub.jsfunction selectIndex(index) { store["selectedIndex"] = index;}// registering with the dispatcherdispatcher.register(message => { switch (message.type) { case "SELECT_INDEX": selectIndex(message.data); // signals to the listener that a change has happened store.emitChange(); break; }});class Store { constructor() ...
Read now
Unlock full access