O'Reilly logo

ReactJS by Example - Building Modern Web Applications with React by Prathamesh Sonpatki, Vipul A M

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required