Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you don't mind sharing, have you done any research on data layers for React? From what I can see, there seems to be three major schools of thought: the Flux architecture, using Backbone's models, or just writing something custom.


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.


I'm currently using Fluxxor[1] which reifies the Flux architecture with Stores and a central dispatcher. I did some research into Backbone.Model bindings but eventually decided to go "full Flux". I've yet to regret my decision even though my app has grown quite complex.

The best part is, thanks to React & Flux I'm building a large scale web app without jQuery for the first time in my life :)

[1] http://fluxxor.com/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: