Skip to content

Instantly share code, notes, and snippets.

@flarnie
Created December 9, 2014 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flarnie/775fe6b392e0421c048c to your computer and use it in GitHub Desktop.
Save flarnie/775fe6b392e0421c048c to your computer and use it in GitHub Desktop.
Flux ChatApp Sample 2
// 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