News for hackers. Stuff that matters.
Re:Flux Application Architecture by hcarvalhoalves on Friday May 09, 2014 @12:53PM (#7721867)
The way I'm integrating Backbone and React that is very simple and has been working well is something like this:

    MyComponent = React.createClass({
        componentDidMount: function(){
            this.props.collection.on('request', function(){
    	       this.setState({loading: true});
            }.bind(this));

            this.props.collection.on('sync', function(){
    	       this.setState({loading: false});
            }.bind(this));

            this.props.collection.fetch();
        },
    });
Now you just write handlers to modify the collection and sync. setState takes care of triggering a render when your collection changes. As a bonus, you might want to render something different while in "loading" state.

If you don't want the component to own the collection (if you want to share a collection between multiple components), just pass it as a prop from a parent component; otherwise you can instantiate a new collection on getDefaultProps.

Re:Flux Application Architecture by wingspan on Friday May 09, 2014 @12:56PM (#7721877)
I believe the latest version of React does autobinding on component methods, so you shouldn't need .bind(this). There should be a warning letting you know this (unless it is different for the public version :/).
Re:Flux Application Architecture by spicyj on Friday May 09, 2014 @02:51PM (#7722634)
These aren't component methods so they don't get autobound -- arrow functions would of course work here though.
Re:Flux Application Architecture by wingspan on Friday May 09, 2014 @04:08PM (#7722988)
Ah of course, I was reading it wrong. Thanks.
Re:Flux Application Architecture by rattray on Friday May 09, 2014 @07:01PM (#7723720)
Thanks! I find this very helpful. Seems like a terrific pattern.
Re:Flux Application Architecture by vjeux on Friday May 09, 2014 @12:59PM (#7721898)
@wingspan: Facebook's runs the exact same code as the open source version, but on master.
Re:Flux Application Architecture by wingspan on Friday May 09, 2014 @01:05PM (#7721938)
Ah right, I thought so. So as long as @hcarvalhoalves is using a recent version they should be fine.