feat: share decorators container
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
10cb22c510
commit
4c0290bf21
@ -11,7 +11,7 @@ function _proxyGetter(
|
|||||||
resolve: () => any,
|
resolve: () => any,
|
||||||
doCache: boolean
|
doCache: boolean
|
||||||
) {
|
) {
|
||||||
function getter() {
|
function getter(this: object) {
|
||||||
if (doCache && !Reflect.hasMetadata(INJECTION, this, key)) {
|
if (doCache && !Reflect.hasMetadata(INJECTION, this, key)) {
|
||||||
Reflect.defineMetadata(INJECTION, resolve(), this, key);
|
Reflect.defineMetadata(INJECTION, resolve(), this, key);
|
||||||
}
|
}
|
||||||
@ -22,7 +22,7 @@ function _proxyGetter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setter(newVal: any) {
|
function setter(this: object, newVal: any) {
|
||||||
Reflect.defineMetadata(INJECTION, newVal, this, key);
|
Reflect.defineMetadata(INJECTION, newVal, this, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import "reflect-metadata";
|
import "reflect-metadata";
|
||||||
|
import { initContainer } from './decorators'
|
||||||
import { interfaces, Container } from 'inversify';
|
import { interfaces, Container } from 'inversify';
|
||||||
import { fluentProvide } from 'inversify-binding-decorators';
|
import { fluentProvide } from 'inversify-binding-decorators';
|
||||||
|
|
||||||
@ -11,6 +12,7 @@ const provideSingleton = (identifier: interfaces.ServiceIdentifier<any>) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const DefaultContainer = new Container();
|
const DefaultContainer = new Container();
|
||||||
|
initContainer(DefaultContainer);
|
||||||
|
|
||||||
export * from 'inversify'
|
export * from 'inversify'
|
||||||
export * from './decorators'
|
export * from './decorators'
|
||||||
|
Loading…
Reference in New Issue
Block a user