Skip to content

Instantly share code, notes, and snippets.

@vojtajina
Created April 21, 2014 19:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vojtajina/11152832 to your computer and use it in GitHub Desktop.
Save vojtajina/11152832 to your computer and use it in GitHub Desktop.
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