bin/lib/store.js
function Store(context, app, data) {
  const state = Object.assign({}, defaultState, data);

  return {
    dispatch(key, payload) {
      const reducers = context.reducers[key];
      /* istanbul ignore next */
      if (!reducers) return;

      for (let i = 0, len = reducers.length; i < len; i += 1) {
        const reducer = reducers[i];
        const newState = reducer.method(state[reducer.namespace], payload);

        if (newState === undefined) {
          debug(
            chalk.bold('Reducer did not return a new state:'),
            chalk.bold.magenta(`${reducer.namespace}.${key}`));
        } else {
          state[reducer.namespace] = newState;
        }
      }

      app.data = Object.assign({}, app.data, state);
    },
    getState() {
      return state;
    },
  };
}
function Store(context, app, data) {
  const state = Object.assign({}, defaultState, data);

  return {
    dispatch(key, payload) {
      const reducers = context.reducers[key];
      /* istanbul ignore next */
      if (!reducers) return;

      for (let i = 0, len = reducers.length; i < len; i += 1) {
        const reducer = reducers[i];
        const newState = reducer.method(state[reducer.namespace], payload);

        if (newState === undefined) {
          debug(
            chalk.bold('Reducer did not return a new state:'),
            chalk.bold.magenta(`${reducer.namespace}.${key}`));
        } else {
          state[reducer.namespace] = newState;
        }
      }

      app.data = Object.assign({}, app.data, state);
    },
    getState() {
      return state;
    },
  };
}
function Store ( context , app , data ) { const state = Object . assign ( { } , defaultState , data ) ; return { dispatch ( key , payload ) { const reducers = context . reducers [ key ] ; /* istanbul ignore next */ if ( ! reducers ) return ; for ( let i = 0 , len = reducers . length ; i < len ; i += 1 ) { const reducer = reducers [ i ] ; const newState = reducer . method ( state [ reducer . namespace ] , payload ) ; if ( newState === undefined ) { debug ( chalk . bold ( 'Reducer did not return a new state:' ) , chalk . bold . magenta ( ` ${ reducer . namespace } ${ key } ` ) ) ; } else { state [ reducer . namespace ] = newState ; } } app . data = Object . assign ( { } , app . data , state ) ; } , getState ( ) { return state ; } , } ; }
The data `Store` is used to manage the session data for the application.
We do not want to manipulate `app.data` directly as it becomes
un-managable as things expand. Instead, we use a `redux` style approach
where the data is managed via state.

To learn more, read the [redux docs](http://redux.js.org/docs/basics/)

@param {App} context the current instance context
@param {Object} app the app response data
@param {Object} data the data to assign to the state on creation
@return {Object} the exposed methods for manipulating the store/state
@private
The data Store is used to manage the session data for the application . We do not want to manipulate app . data directly as it becomes un - managable as things expand . Instead we use a redux style approach where the data is managed via state .