di.js icon indicating copy to clipboard operation
di.js copied to clipboard

Better dependencies syntax

Open NickQiZhu opened this issue 11 years ago • 0 comments

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'
    },);
}

NickQiZhu avatar Oct 17 '13 20:10 NickQiZhu