container-ioc icon indicating copy to clipboard operation
container-ioc copied to clipboard

Cleanup interface IProvider

Open basedalexander opened this issue 8 years ago • 2 comments

I messed up interfaces for registered providers within Containers. They can't even be exported.

basedalexander avatar Oct 01 '17 23:10 basedalexander

Hey I started looking a bit into this one last night, I'll try to get something and submit a PR. I'm thinking something like an interface per second param in the existing method e.g. IProvideClass, IProvideFactory, etc.

Tolowe avatar Dec 02 '17 18:12 Tolowe

@Tolowe I thought of something like defining several interfaces named the same way. Buy they are structured a little bit differently.

interface IProvider { token: InjectionToken, useClass: Constructor }
interface IProvider { token: InjectionToken, useValue: InjectionValue }
interface IProvider { token: InjectionToken, useFactory: InjectionFactory }

Something like this. I've seen this technique is used a lot in libraries. Users of that container should clearly understand what object format should be provided. It's not really that important at this moment, but if you have some time to implement this, let us know here :)

basedalexander avatar Dec 02 '17 19:12 basedalexander