@appolo/inject
Advanced tools
Comparing version 8.0.14 to 8.0.15
@@ -20,2 +20,3 @@ "use strict"; | ||
const _initBootstrapMethods_1 = require("../methods/methods/_initBootstrapMethods"); | ||
const _prepareProperties_1 = require("../methods/properties/_prepareProperties"); | ||
exports.IsWiredSymbol = "@__isWired__"; | ||
@@ -114,2 +115,11 @@ class Injector { | ||
} | ||
wire(klass, runtimeArgs) { | ||
let def = util_1.Util.getClassDefinition(klass); | ||
if (!def) { | ||
} | ||
def = def.clone(); | ||
_prepareProperties_1._prepareProperties.call(this, def.definition); | ||
let instance = _get_1._getFromDefinition.call(this, def.definition, def.definition.id, []); | ||
return instance; | ||
} | ||
get(objectID, runtimeArgs) { | ||
@@ -116,0 +126,0 @@ objectID = util_1.Util.getClassNameOrId(objectID); |
@@ -11,3 +11,3 @@ "use strict"; | ||
import {_get} from "../methods/instances/_get"; | ||
import {_get, _getFromDefinition} from "../methods/instances/_get"; | ||
@@ -27,2 +27,3 @@ import {_register} from "../methods/definitions/_register"; | ||
import {_initBootstrapMethods} from "../methods/methods/_initBootstrapMethods"; | ||
import {_prepareProperties} from "../methods/properties/_prepareProperties"; | ||
@@ -185,2 +186,17 @@ type keyObject = { [index: string]: Object } | ||
public wire<T extends new (...args: any) => any>(klass: T, runtimeArgs?: ConstructorParameters<T>): InstanceType<T> { | ||
let def = Util.getClassDefinition(klass) | ||
if (!def) { | ||
} | ||
def = def.clone(); | ||
_prepareProperties.call(this, def.definition); | ||
let instance = _getFromDefinition.call(this, def.definition, def.definition.id, []) as InstanceType<T> | ||
return instance; | ||
} | ||
public get<T>(objectID: string | Function, runtimeArgs?: any[]): T { | ||
@@ -187,0 +203,0 @@ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports._get = void 0; | ||
exports._getFromDefinition = exports._get = void 0; | ||
const _createObjectInstance_1 = require("./_createObjectInstance"); | ||
@@ -12,5 +12,3 @@ function _get(objectID, runtimeArgs) { | ||
if (def) { | ||
return def.injector && def.injector !== this | ||
? def.injector.getObject(def.refName || objectID, runtimeArgs) | ||
: _createObjectInstance_1._createObjectInstance.call(this, objectID, this._definitions[objectID], runtimeArgs); | ||
return _getFromDefinition.call(this, def, objectID, runtimeArgs); | ||
} | ||
@@ -23,2 +21,8 @@ if (this.parent) { | ||
exports._get = _get; | ||
function _getFromDefinition(def, objectID, runtimeArgs) { | ||
return def.injector && def.injector !== this | ||
? def.injector.getObject(def.refName || objectID, runtimeArgs) | ||
: _createObjectInstance_1._createObjectInstance.call(this, objectID, def, runtimeArgs); | ||
} | ||
exports._getFromDefinition = _getFromDefinition; | ||
//# sourceMappingURL=_get.js.map |
import {Injector} from "../../inject/inject"; | ||
import {_createObjectInstance} from "./_createObjectInstance"; | ||
import {IDefinition} from "../../interfaces/IDefinition"; | ||
@@ -15,5 +16,3 @@ export function _get<T>(this: Injector, objectID: string, runtimeArgs?: any[]): T { | ||
if (def) { | ||
return def.injector && def.injector !== this | ||
? def.injector.getObject(def.refName || objectID, runtimeArgs) | ||
: _createObjectInstance.call(this,objectID, this._definitions[objectID], runtimeArgs) as T; | ||
return _getFromDefinition.call(this, def, objectID, runtimeArgs) as T | ||
} | ||
@@ -27,1 +26,8 @@ | ||
} | ||
export function _getFromDefinition<T>(this: Injector, def: IDefinition, objectID: string, runtimeArgs?: any[]): T { | ||
return def.injector && def.injector !== this | ||
? def.injector.getObject(def.refName || objectID, runtimeArgs) | ||
: _createObjectInstance.call(this, objectID, def, runtimeArgs) as T; | ||
} | ||
@@ -34,3 +34,3 @@ { | ||
"main": "./index.js", | ||
"version": "8.0.14", | ||
"version": "8.0.15", | ||
"license": "MIT", | ||
@@ -37,0 +37,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
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
223390
3428