young-steveo / bottlejs

A powerful dependency injection micro container for JavaScript applications
MIT License
1.29k stars 67 forks source link

inject dependencies automatically whenever their names are the same #112

Closed buckelieg closed 6 years ago

buckelieg commented 6 years ago

From the example:

var bottle = new Bottle();
bottle.service('Barley', Barley);
bottle.service('Hops', Hops);
bottle.service('Water', Water);
bottle.service('Beer', 
function(barley, hops, water) {
...
}, 
'Barley', 'Hops', 'Water'
);

Omit string declarations after function if we declare tis arguments with the same object names as we registered before:

var bottle = new Bottle();
bottle.service('Barley', Barley);
bottle.service('Hops', Hops);
bottle.service('Water', Water);
bottle.service('Beer', 
function(Barley, Hops, Water) {
...
});
young-steveo commented 6 years ago

This will not work if the javascript is minified.

young-steveo commented 6 years ago

See my comments on it here: https://github.com/young-steveo/bottlejs/issues/3#issuecomment-57213962