Created
April 21, 2014 19:01
-
-
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...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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