Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

Subscribe function

What you have done is already impressive, but it can get a little bit better or more efficient to be more accurate. 

If you notice, after every dispatch, we want to take a look and see what the current state is, thus we print it the console. If you want something to happen after every dispatch is triggered, you can create a hook, by using the stores subscribe method

As shown above the subscribe method of a store accepts a callback function that will be executed any time a dispatch method of the same store is called, immediately after it.

Important note: You must define the subscribe BEFORE any dispatch, in order to see everything. The subscribe's callback will be executed every time a dispatch method, that has been defined AFTER subscription, is called. The previous ones will be ignored.