di.js
di.js copied to clipboard
Better dependencies syntax
Currently, we have this:
var SomeClass = function() {
this.dependencies = ['someDep_=SomeService, someOtherDep_=SomeOtherService'];
ctx.initialize();
}
Registering dependencies as a string seems little clunky, and having a shared ctx container modify all of my class instances by parsing a string on an arbitrary property scares me ever so slightly.
How about something like this:
var SomeClass = function() {
ctx.bakeDependenciesInto(this, {
'someDep_': 'SomeService',
'someOtherDep_': 'SomeOtherService'
},);
}