Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
One possible way of doing configuration with DI. I think we need something nicer...
function Config() {
this.useFoo = false;
this.log = 'infoo;
}
@Inject(Config)
class SomeService{
constructor(config) {
// ...
}
}
// Using a different config
@Provide(Config)
function DebugConfig() {
this.useFoo = true;
this.someBar = 1111;
}
var injector = new Injector([DebugConfig]);
injector.get(SomeService);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment