You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Very cool library, type safety is especially nice!
We currently use inversify, and in toDynamicValue you get Context as an argument. In the context you can look up the token of the target where the current value is injected into. We use that for logging purposes.
With the magic token TARGET_TOKEN I am able to get the name of the constructor that requested this value. But I also would like the token, as we can give some more context in the token than the class name.
Is there way this is currently possible?
Minimal example:
functionTestFactory(target: Function|undefined){// Here I would like to get access to the token of the target.console.log(target)// [Function: MagicTokenTest] { inject: [ 'TestFactory' ] }return'hello, world!'}TestFactory.inject=[TARGET_TOKEN]asconstclassMagicTokenTest{publicstaticinject=['TestFactory']asconstconstructor(testFactory: string){}}constappInjector=createInjector().provideFactory('TestFactory',TestFactory,Scope.Transient).provideClass('token.i.use.for.logging',MagicTokenTest);appInjector.resolve('token.i.use.for.logging');
The text was updated successfully, but these errors were encountered:
Very cool library, type safety is especially nice!
We currently use inversify, and in
toDynamicValue
you getContext
as an argument. In the context you can look up the token of the target where the current value is injected into. We use that for logging purposes.With the magic token
TARGET_TOKEN
I am able to get the name of the constructor that requested this value. But I also would like the token, as we can give some more context in the token than the class name.Is there way this is currently possible?
Minimal example:
The text was updated successfully, but these errors were encountered: