3 ms·
I used React+Flux for a level editor for a game recently. It seemed to me like there was one or two too many levels of indirection. Specifically, I'm not sure
by yoklov 11y ago
I used React+Flux for a level editor for a game recently. It seemed to me like there was one or two too many levels of indirection.
Specifically, I'm not sure what problem the Dispatcher is actually solving. It seems to just add boilerplate and indirection for little benefit.
- danmaz74 11y agoThe 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.