Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "mobidic", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"keywords": [], | ||
@@ -5,0 +5,0 @@ "author": "js2me", |
24
tag.js
@@ -13,6 +13,15 @@ const mark = Symbol('di'); | ||
}; | ||
this.strategy = | ||
(this.config.strategy ?? typeof this.config.token === 'function') | ||
? 'class-constructor' | ||
: 'token'; | ||
if (this.config.strategy) { | ||
this.strategy = this.config.strategy; | ||
} | ||
else if (typeof this.config.token === 'function') { | ||
this.strategy = 'class-constructor'; | ||
this.config.classConstructor = this.config.token; | ||
} | ||
else if (this.config.classConstructor) { | ||
this.strategy = 'class-constructor'; | ||
} | ||
else { | ||
this.strategy = 'token'; | ||
} | ||
this.injectConfig = { | ||
@@ -22,5 +31,4 @@ __: this.config.__, | ||
}; | ||
if (this.strategy === 'class-constructor' && | ||
typeof this.config.token === 'function') { | ||
Object.assign(this.config.token, { | ||
if (this.strategy === 'class-constructor') { | ||
Object.assign(this.config.classConstructor, { | ||
[mark]: this, | ||
@@ -32,3 +40,3 @@ }); | ||
if (this.strategy === 'class-constructor') { | ||
return new this.config.token(...args); | ||
return new this.config.classConstructor(...args); | ||
} | ||
@@ -35,0 +43,0 @@ if (this.config.value) { |
@@ -10,2 +10,3 @@ import { Class } from 'yummies/utils/types'; | ||
value?: (...args: TArgs) => TTarget; | ||
classConstructor?: Class<TTarget>; | ||
strategy?: 'class-constructor' | 'token'; | ||
@@ -12,0 +13,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
25965
457