mmlpx
Version:
mobx model layer paradigm
39 lines (33 loc) • 1.32 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = initialize;
var _meta = require('../meta');
var _execPostConstruct = require('./execPostConstruct');
var _execPostConstruct2 = _interopRequireDefault(_execPostConstruct);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* @author Kuitos
* @homepage https://github.com/kuitos/
* @since 2017-09-13
*/
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[_meta.modelNameSymbol];
var store = injector.get(Store, { scope: "singleton" /* Singleton */, name: name });
(0, _execPostConstruct2.default)(store);
return store;
}
;