Skip to content

Instantly share code, notes, and snippets.

@flarnie
Created December 9, 2014 00:50
Show Gist options
  • Save flarnie/6c6c53f723a9f1703ab4 to your computer and use it in GitHub Desktop.
Save flarnie/6c6c53f723a9f1703ab4 to your computer and use it in GitHub Desktop.
Flux TodoApp Sample 8
// The component listens for changes and calls the '_onChange' callback
// ...
var TodoApp = React.createClass({
getInitialState: function() {
return getTodoState();
},
componentDidMount: function() {
TodoStore.addChangeListener(this._onChange);
},
componentWillUnmount: function() {
TodoStore.removeChangeListener(this._onChange);
},
// ...
/**
* Event handler for 'change' events coming from the TodoStore
*/
_onChange: function() {
this.setState(getTodoState());
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment