In order to operate in a multi context environment like node, we pass around a context object that ensures data is appropriately assigned to the proper requests.

Each context is assigned its own dispatcher, store and action instances.

Using the plugin infrastructure or by passing custom context methods to the createContext method, we can extend this context provided to components, actions and stores.

Using in Actions

The context is exposed as property "context"
fluxApp.registerActions('user', {
  search: function(property) {
    var criteria = this.context.getStore('userSearchCriteria');
  }
});

Using in Stores

The context is exposed as property "context"

fluxApp.registerStore('userSearchResults', {
  actions: {
    onUserSearch: ['user.search', 'friend.search']
  },
  
  onUserSearch: function(results, actionType) {
    var userSearch = this.context.getActionType('user.search');
    
    if (userSearch === actionType) {
      // user search 
    } else {
      // friend search
    }
  }
});

Using in React Components

The context is provided under getFlux if the component mixin is used, if not it is available under the this.context.flux property.

React.createClass({
  mixins: [fluxapp.mixins.component],
  
  getInitialState: function() {
    var store = this.getStore('name');
    
    //alternatively without the mixin above
    store = this.context.flux.getStore('name');
    
    return {
      name: store.getState() 
    };
  }
});

👍

On to Custom Context Methods