@injex/core
Advanced tools
Comparing version 3.2.1 to 3.3.0
@@ -288,5 +288,23 @@ "use strict"; | ||
InjexContainer.prototype._invokeModuleReadyMethod = function (module, metadata) { | ||
var _this = this; | ||
if (this.config.asyncModuleInit) { | ||
return new Promise(function (resolve) { | ||
setTimeout(function () { | ||
var promise = _this._invokeMetadataModuleMethod(module, metadata, 'readyMethod'); | ||
stdlib_1.isPromise(promise) ? promise.then(resolve) : resolve(); | ||
}); | ||
}); | ||
} | ||
return this._invokeMetadataModuleMethod(module, metadata, 'readyMethod'); | ||
}; | ||
InjexContainer.prototype._invokeModuleInitMethod = function (module, metadata) { | ||
var _this = this; | ||
if (this.config.asyncModuleInit) { | ||
return new Promise(function (resolve) { | ||
setTimeout(function () { | ||
var promise = _this._invokeMetadataModuleMethod(module, metadata, 'initMethod', _this._onInitModuleError); | ||
stdlib_1.isPromise(promise) ? promise.then(resolve) : resolve(); | ||
}); | ||
}); | ||
} | ||
return this._invokeMetadataModuleMethod(module, metadata, 'initMethod', this._onInitModuleError); | ||
@@ -293,0 +311,0 @@ }; |
@@ -60,2 +60,10 @@ import { Hook, IConstructor, LogLevel } from "@injex/stdlib"; | ||
plugins?: IInjexPlugin[]; | ||
/** | ||
* Separate each module @init() to a separate task to prevent | ||
* long task while initializing container modules. | ||
* | ||
* @type Boolean | ||
* @default false | ||
*/ | ||
asyncModuleInit?: boolean; | ||
} | ||
@@ -62,0 +70,0 @@ export interface ILazyModule<T> { |
{ | ||
"name": "@injex/core", | ||
"version": "3.2.1", | ||
"version": "3.3.0", | ||
"description": "Simple, Decorated, Pluggable dependency-injection framework for TypeScript apps", | ||
@@ -47,3 +47,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@injex/stdlib": "^3.2.1" | ||
"@injex/stdlib": "^3.3.0" | ||
}, | ||
@@ -57,3 +57,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "92c874b3a2e9e57ac96214f96a5ce4f5b54a7d9d" | ||
"gitHead": "7a0c48970c4204a5db67fdbe85e37609469f581a" | ||
} |
@@ -315,2 +315,11 @@ import { Hook, IConstructor, isFunction, isPromise, Logger } from "@injex/stdlib"; | ||
private _invokeModuleReadyMethod(module: any, metadata: IDefinitionMetadata): Promise<any> | any { | ||
if (this.config.asyncModuleInit) { | ||
return new Promise<void>((resolve) => { | ||
setTimeout(() => { | ||
const promise = this._invokeMetadataModuleMethod(module, metadata, 'readyMethod'); | ||
isPromise(promise) ? promise.then(resolve) : resolve(); | ||
}); | ||
}); | ||
} | ||
return this._invokeMetadataModuleMethod(module, metadata, 'readyMethod'); | ||
@@ -320,2 +329,11 @@ } | ||
private _invokeModuleInitMethod(module: any, metadata: IDefinitionMetadata): Promise<any> | any { | ||
if (this.config.asyncModuleInit) { | ||
return new Promise<void>((resolve) => { | ||
setTimeout(() => { | ||
const promise = this._invokeMetadataModuleMethod(module, metadata, 'initMethod', this._onInitModuleError); | ||
isPromise(promise) ? promise.then(resolve) : resolve(); | ||
}); | ||
}); | ||
} | ||
return this._invokeMetadataModuleMethod(module, metadata, 'initMethod', this._onInitModuleError); | ||
@@ -322,0 +340,0 @@ } |
@@ -70,2 +70,11 @@ import { Hook, IConstructor, LogLevel } from "@injex/stdlib"; | ||
plugins?: IInjexPlugin[]; | ||
/** | ||
* Separate each module @init() to a separate task to prevent | ||
* long task while initializing container modules. | ||
* | ||
* @type Boolean | ||
* @default false | ||
*/ | ||
asyncModuleInit?: boolean; | ||
} | ||
@@ -72,0 +81,0 @@ |
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
90126
1535
Updated@injex/stdlib@^3.3.0