2 ms·
Still working on the data layer, but I think I'm going to use Reflux. One of the things I was initially skeptical of React about is its lack of support for cus
by bsimpson 12y ago
Still working on the data layer, but I think I'm going to use Reflux. One of the things I was initially skeptical of React about is its lack of support for custom event bubbling (which is the technique I like to use to keep my components decoupled).
Flux lets you cheat around that: Since you're using require statements, you can make an action and `require()` it in both the component it's dispatched from and the one that's listening to it.
// Traditional event bubbling
child.dispatchEvent(...) ----> parent.addEventListener(...)
// Reflux
child:action() ----> store.listenTo(action) ----> store.trigger(data) ----> parent.listenTo(store)
The store is an extra layer of abstraction, so you can assimilate data from different sources (user interaction, server events, etc) into one format before passing them into your datastream. Facebook's Flux has yet another layer of abstraction called the Dispatcher.
Honestly, I'm murky on the utility of the Store and even less confident in the utility of the Dispatcher. That's why I'm using Reflux instead of FBFlux, and I'm still tempted to skip the store and just listen to my actions from the parent component.