Building a dispatcher module
In this section, we're going to implement our own dispatcher module. This will serve as a replacement for the Facebook reference implementation that we've relied upon so far in this book. First, we'll think about how the dispatcher will track references to store modules. Then, we'll discuss the functions that this module needs to expose, followed by a walk-through of the
dispatch() implementation. Lastly, we'll figure out how we want to handle dependency management with this dispatcher module.
Encapsulating store references
The first aspect of our dispatcher module to consider are the stores themselves. With Facebook's reference implementation, there are no references to stores—only references to callback functions. ...