Created
December 9, 2014 00:50
-
-
Save flarnie/6c6c53f723a9f1703ab4 to your computer and use it in GitHub Desktop.
Flux TodoApp Sample 8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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