joist
joist copied to clipboard
Create a non constructable ProviderToken
At the moment we assume that all tokens are constructable. This works for 99% of use cases. There are often times where you might want to inject someone other than an object or want to require a specific definition.
An 'InjectionToken<T>' will define a specific symbol to be used in the injection and define the type that the symbol should resolve to.
const token = new InjectionToken();
const providers = [{ provide: token, factory: () => {}]
The injector would return an error if it is unable to find a provider for the particular token.