@injex/core
Advanced tools
Comparing version 2.0.0-alpha.6 to 2.0.0-alpha.7
@@ -36,2 +36,3 @@ import { IConstructor, Logger } from "@injex/stdlib"; | ||
private _invokeModuleInitMethod; | ||
private _onInitModuleError; | ||
private _createInstance; | ||
@@ -38,0 +39,0 @@ getModuleDefinition(moduleNameOrType: ModuleName | IConstructor): IModule; |
@@ -179,2 +179,3 @@ "use strict"; | ||
return function factory() { | ||
var _this = this; | ||
var args = []; | ||
@@ -184,16 +185,11 @@ for (var _i = 0; _i < arguments.length; _i++) { | ||
} | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var instance; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
instance = self._createInstance(construct, args); | ||
self._injectModuleDependencies(instance, metadata); | ||
return [4 /*yield*/, self._invokeModuleInitMethod(instance, metadata)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, instance]; | ||
} | ||
}); | ||
}); | ||
var instance = self._createInstance(construct, args); | ||
self._injectModuleDependencies(instance, metadata); | ||
var initValue = self._invokeModuleInitMethod(instance, metadata); | ||
if (stdlib_1.isPromise(initValue)) { | ||
return initValue | ||
.then(function () { return instance; }) | ||
.catch(function (err) { return _this._onInitModuleError(metadata, err); }); | ||
} | ||
return instance; | ||
}; | ||
@@ -228,24 +224,15 @@ }; | ||
InjexContainer.prototype._invokeModuleInitMethod = function (module, metadata) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var e_2; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!(metadata.initMethod && stdlib_1.isFunction(module[metadata.initMethod]))) return [3 /*break*/, 4]; | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, module[metadata.initMethod]()]; | ||
case 2: | ||
_a.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
e_2 = _a.sent(); | ||
this._logger.error(e_2); | ||
throw new errors_1.InitializeMuduleError(metadata.name); | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
if (metadata.initMethod && stdlib_1.isFunction(module[metadata.initMethod])) { | ||
try { | ||
return module[metadata.initMethod](); | ||
} | ||
catch (e) { | ||
this._onInitModuleError(metadata, e); | ||
} | ||
} | ||
}; | ||
InjexContainer.prototype._onInitModuleError = function (metadata, err) { | ||
this._logger.error(err); | ||
throw new errors_1.InitializeMuduleError(metadata.name); | ||
}; | ||
InjexContainer.prototype._createInstance = function (construct, args) { | ||
@@ -252,0 +239,0 @@ if (args === void 0) { args = []; } |
{ | ||
"name": "@injex/core", | ||
"version": "2.0.0-alpha.6", | ||
"version": "2.0.0-alpha.7", | ||
"description": "Simple, Decorated, Pluggable dependency-injection framework for TypeScript apps", | ||
@@ -46,3 +46,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@injex/stdlib": "^2.0.0-alpha.6", | ||
"@injex/stdlib": "^2.0.0-alpha.7", | ||
"tslib": "^2.0.1" | ||
@@ -56,3 +56,3 @@ }, | ||
}, | ||
"gitHead": "2bc7bf1fe723764bbc83c4425e202dca101ec87a" | ||
"gitHead": "a8b5803004122e95f1fd4d4b7c34c7f78511268d" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44870
649
Updated@injex/stdlib@^2.0.0-alpha.7