ioc-service-container
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -8,4 +8,10 @@ # Changelog | ||
## [1.2.1] - 2020-03-22 | ||
## [1.3.0] - 2021-05-12 | ||
### Added | ||
* Parameter `buildInstantly` to `ServiceContainer.set()` for forcing to build the instance of a service directly | ||
## [1.2.1] - 2021-03-22 | ||
### Fixed | ||
@@ -15,3 +21,3 @@ | ||
## [1.2.0] - 2020-03-22 | ||
## [1.2.0] - 2021-03-22 | ||
@@ -22,3 +28,3 @@ ### Added | ||
## [1.1.1] - 2020-02-18 | ||
## [1.1.1] - 2021-02-18 | ||
@@ -29,3 +35,3 @@ ### Changed | ||
## [1.1.0] - 2020-02-16 | ||
## [1.1.0] - 2021-02-16 | ||
@@ -36,3 +42,3 @@ ### Changed | ||
## [1.0.0] - 2020-02-15 | ||
## [1.0.0] - 2021-02-15 | ||
@@ -43,3 +49,3 @@ ### Added | ||
## [0.1.3] - 2020-02-02 | ||
## [0.1.3] - 2021-02-02 | ||
@@ -54,3 +60,3 @@ ### Added | ||
## [0.1.2] - 2020-02-02 | ||
## [0.1.2] - 2021-02-02 | ||
@@ -57,0 +63,0 @@ ### Added |
declare const _default: { | ||
set(id: string, factory: () => any): void; | ||
/** | ||
* | ||
* @param id to identify the service in the container, it can be mapped to a property name via the inject decorator | ||
* @param factory to create the instance of the service | ||
* @param buildInstantly by default the service is only instantiated on demand, if required your are able to build the service directly | ||
*/ | ||
set(id: string, factory: () => any, buildInstantly?: boolean): void; | ||
get<T>(id: string): T; | ||
@@ -4,0 +10,0 @@ override(id: string, factory: () => any): void; |
@@ -5,3 +5,9 @@ "use strict"; | ||
exports.default = { | ||
set(id, factory) { | ||
/** | ||
* | ||
* @param id to identify the service in the container, it can be mapped to a property name via the inject decorator | ||
* @param factory to create the instance of the service | ||
* @param buildInstantly by default the service is only instantiated on demand, if required your are able to build the service directly | ||
*/ | ||
set(id, factory, buildInstantly = false) { | ||
const lowerId = id.toLowerCase(); | ||
@@ -13,3 +19,4 @@ if (services.find(s => s.id === lowerId) !== undefined) { | ||
id: lowerId, | ||
factory | ||
factory, | ||
instance: buildInstantly ? factory() : undefined, | ||
}); | ||
@@ -16,0 +23,0 @@ }, |
{ | ||
"name": "ioc-service-container", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Lightweight ioc service container", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
12637
108