2 ms·
The most popular library to implement Flux, reflux, actually does away with the dispatcher. But during my research I read many posts showing that having the dis
by danmaz74 11y ago
The most popular library to implement Flux, reflux, actually does away with the dispatcher. But during my research I read many posts showing that having the dispatcher is actually a good idea; just off the top of my head: it makes debugging easier, and it allows you to enforce the "waitFor" mechanism to coordinate the update order of the different stores.
I even think it could also be used for one more goal.
With standard Flux, if an action updates multiple stores, and a ModelController is dependent on those multiple stores, that ModelController will get rendered (to the virtual DOM) multiple times, which is inefficient.
If instead the stores notified the dispatcher that they were updated, and then it was the dispatcher to dispatch all the "change" events to the ViewControllers only once (ie: if a ViewController is dependent on two different stores, and they were both "changed", it would still only get one "change" event) this would make those situations much more efficient.