UNPKG

mobx-create-stores

Version:

creates an object with MobX stores (+ links stores to routes)

38 lines (27 loc) 915 B
import createRouterStore from './createRouterStore'; import createStore from './createStore'; import getStoreName from './getStoreName'; export default (function () { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, st = _ref.stores, _ref$history = _ref.history, h = _ref$history === undefined ? false : _ref$history; var routerStore = void 0, history = void 0; var stores = {}; if (h) { var _createRouterStore = createRouterStore(h); history = _createRouterStore.history; routerStore = _createRouterStore.routerStore; } st = st.map(function (Store) { return createStore({ Store: Store, history: history }); }); if (h) st.push(routerStore); st.forEach(function (s) { var name = getStoreName(s); stores[name] = s; if (process.env.NODE_ENV !== 'production') window[name] = s; }); return stores; });