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
Generally IoC container allow self injection. I will demonstrate in C#. This is to demonstrate that this approach is common and supported by other frameworks (example below demonstrate .NET Core's IoC container).
classFoo{publicIServiceProviderProvider{get;}publicFoo(IServiceProviderprovider)// this is DI container {Provider=provider;}}IServiceCollectionservices=newServiceCollection();services.AddTransient<Foo>();// register to DIIServiceProviderprovider=services.BuildServiceProvider();// build container;varfoo=provider.GetService<Foo>();foo.Provider==provider;// true
In this case, constructor recieve instance that is constructing given type. This means that child containers propagte their own instance.
Uncaught Error: No matching bindings found for serviceIdentifier: Container
at _validateActiveBindingCount (planner.js:59:1)
at _getActiveBindings (planner.js:45:1)
at _createSubRequests (planner.js:86:1)
at planner.js:110:1
at Array.forEach ()
at planner.js:109:1
at Array.forEach ()
at _createSubRequests (planner.js:89:1)
at plan (planner.js:131:1)
at container.js:598:31
Your Environment
Version used: 6.0.1
The text was updated successfully, but these errors were encountered:
But this is somewhat a hack as ctx.container is not class Container but interface Container and I cast it to the class (watchout, you cannot be sure that ctx.container is an instance of that class as it might be a different subtype; However, as of now it is instnace of that class).
Expected Behavior
Generally IoC container allow self injection. I will demonstrate in C#. This is to demonstrate that this approach is common and supported by other frameworks (example below demonstrate .NET Core's IoC container).
In this case, constructor recieve instance that is constructing given type. This means that child containers propagte their own instance.
Usecase in TypeScript:
Current Behavior
Uncaught Error: No matching bindings found for serviceIdentifier: Container
at _validateActiveBindingCount (planner.js:59:1)
at _getActiveBindings (planner.js:45:1)
at _createSubRequests (planner.js:86:1)
at planner.js:110:1
at Array.forEach ()
at planner.js:109:1
at Array.forEach ()
at _createSubRequests (planner.js:89:1)
at plan (planner.js:131:1)
at container.js:598:31
Your Environment
The text was updated successfully, but these errors were encountered: