As the name aptly defines, Flux dispatchers dispatches the actions to the subsequent stores. Dispatchers can be called as a registry of callbacks. All the stores are registered with the dispatchers.
Some key points of dispatcher are the following:
There is only one dispatcher per app.
Dispatchers being used as a center for all the registered callbacks.
It functions as a broadcaster of all the actions to the stores. Dispatchers acts as a queue, which sequentially broadcasts the actions. This is different from generic pub-sub systems in the following two ways:
Callbacks are not subscribed to particular events. Every payload is dispatched to every registered callback.
Callbacks can be deferred in whole or part until other callbacks have been executed.
The dispatcher has the capability to invoke the callbacks in the order specified, and it waits for other updates (
waitFor()
method does that).In the flux library (
npm install flux
)node_module
, theregister()
anddispatch()
methods are defined...