Flux stores
"Cool, it looks like now we are all set to create our store."
"Yup Shawn. We will start by defining the state object that we will keep on updating and using as a store."
var AppDispatcher = require('../dispatcher/AppDispatcher'); var EventEmitter = require('events').EventEmitter; var SocialConstants = require('../constants/SocialConstants'); var assign = require('object-assign'); var _ = require('underscore'); var CHANGE_EVENT = 'change'; var _state = { tweets: [], reddits: [], feed: [], showTweets: true, showReddits: true };
"We have also defined a CHANGE_EVENT
constant that we use as an identifier to listen to events of the change type from the event emitter in our store."
"We then define a method to update the states, creating a new one."
function updateState(state) { _state = assign({}, _state, state); }
"This merges the new properties that need to be updated...