Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (29 sloc) 786 Bytes

createStore

import createStore from 'fluxible/addons/createStore';

A helper method similar to React.createClass but for creating stores that extend BaseStore. Also supports mixins.

Example

export default createStore({
    storeName: 'ApplicationStore',
    handlers: {
        'RECEIVE_PAGE': 'handleReceivePage'
    },
    handleReceivePage: function (payload) {
        this.currentPageName = payload.pageName;
        this.emitChange();
    },
    getCurrentPage: function () {
        return this.currentPageName;
    },
    dehydrate: function () {
        return {
            currentPageName: this.currentPageName
        };
    },
    rehydrate: function (state) {
        this.currentPageName = state.currentPageName;
    }
});