UNPKG

mmlpx

Version:

mobx model layer paradigm

26 lines 1.04 kB
/** * @author Kuitos * @homepage https://github.com/kuitos/ * @since 2017-09-13 */ import { modelNameSymbol } from '../meta'; import execPostConstruct from './execPostConstruct'; export default function initialize(injector, Store) { var args = []; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } // store should not initialize dynamically while injecting if (args && args.length) { /* istanbul ignore else */ if (process.env.NODE_ENV === 'test') { throw new SyntaxError(Store.name + ": As a singleton recipe, you should not instantiate Store with dynamic arguments!"); } else if (process.env.NODE_ENV !== 'production') { console.error(Store.name + ": As a singleton recipe, you should not instantiate Store with dynamic arguments!"); } } var name = Store[modelNameSymbol]; var store = injector.get(Store, { scope: "singleton" /* Singleton */, name: name }); execPostConstruct(store); return store; }