Skip to content

Instantly share code, notes, and snippets.

@flarnie
Created December 9, 2014 00:55
Show Gist options
  • Save flarnie/8209fdf07d1d192f5d05 to your computer and use it in GitHub Desktop.
Save flarnie/8209fdf07d1d192f5d05 to your computer and use it in GitHub Desktop.
Flux ChatApp Sample 1
// The case statement documents which actions this store listens to
// ...
ThreadStore.dispatchToken = ChatAppDispatcher.register(function(payload) {
var action = payload.action;
switch(action.type) {
case ActionTypes.CLICK_THREAD:
_currentID = action.threadID;
_threads[_currentID].lastMessage.isRead = true;
ThreadStore.emitChange();
break;
case ActionTypes.RECEIVE_RAW_MESSAGES:
ThreadStore.init(action.rawMessages);
ThreadStore.emitChange();
break;
default:
// do nothing
}
});
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment