One of the store's jobs has been to handle eventing, especially when the store wants to convey to a view that a change has happened to its state. In the store.js file, other things were happening as well, things like registering ourselves with the dispatcher and being able to receive dispatched actions. We used these actions to alter the state of the store. Let's remind ourselves what that looked like:
// store.jslet store = {};function selectIndex(index) { store["selectedIndex"] = index;}dispatcher.register(message => { switch (message.type) { case "SELECT_INDEX": selectIndex(message.data); break; }});
Here, we are only supporting one action, namely SELECT_INDEX. There are two things we need ...