Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manually register and create #31

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

uetkaje
Copy link

@uetkaje uetkaje commented Nov 13, 2015

Hi,

I've encountered some hassle when I use electrolyte. Here are;

  • Electrolyte automatically register components while first attempt to use, if not registered yet. Nice feature. But some case, I need to register components immediately. Not waiting to be registered by another component. Example:
var IoC = require('electrolyte');
var arg = function () {
    return 'arg';
};
arg['@singleton'] = true;
IoC.register('arg', arg);

var r = IoC.create('arg');
console.log(r);
  • Electrolyte automatically create components and resolve whole dependency tree. Some case, I need to provide component dependencies dynamically. It would be nice, if dependencies passed to component with an array.
//index.js
var IoC = require('electrolyte');
IoC.use(IoC.node('./components'));

var r1 = IoC.create('test', [
    'emre'
]);
console.log(r1);

var r2 = IoC.create('test', [
    IoC.create('arg1')
]);
console.log(r2);
//components/test.js
exports = module.exports = function (arg1) {
    return arg1;
};
exports['@require'] = ['arg1'];
exports['@singleton'] = true;
//components/arg1.js
exports = module.exports = function () {
    return 'arg1';
};
exports['@singleton'] = true;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant