Created
December 9, 2014 00:57
-
-
Save flarnie/775fe6b392e0421c048c to your computer and use it in GitHub Desktop.
Flux ChatApp Sample 2
This file contains 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
// Looking at the 'componentDidMount' will usually show | |
// whic stores this component listens to. | |
// ... | |
function getStateFromStores() { | |
return { | |
threads: ThreadStore.getAllChrono(), | |
currentThreadID: ThreadStore.getCurrentID(), | |
unreadCount: UnreadThreadStore.getCount() | |
}; | |
} | |
var ThreadSection = React.createClass({ | |
getInitialState: function() { | |
return getStateFromStores(); | |
}, | |
componentDidMount: function() { | |
ThreadStore.addChangeListener(this._onChange); | |
UnreadThreadStore.addChangeListener(this._onChange); | |
}, | |
componentWillUnmount: function() { | |
ThreadStore.removeChangeListener(this._onChange); | |
UnreadThreadStore.removeChangeListener(this._onChange); | |
}, | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment