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

Nested modules with same name, AKA namespacing #14

Open
colthreepv opened this issue Jul 3, 2015 · 1 comment
Open

Nested modules with same name, AKA namespacing #14

colthreepv opened this issue Jul 3, 2015 · 1 comment

Comments

@colthreepv
Copy link
Contributor

Hello, I'm trying to convert myself to using simple-ioc, from jaredhanson/electrolyte, a functionality that seems simple but quite powerful is natural namespacing via strings.

Example follows:

module.exports = exports = function (listBlogposts) {
  // clever controller logic
  return {};
};
exports['@require'] = ['api/list-blogposts'];

In case I also have a controller for the same operation, but returns a page (instead of an API), i can do this:

module.exports = exports = function (listBlogposts) {
  // clever controller logic
  return {};
};
exports['@require'] = ['controller/list-blogposts'];

// or even

module.exports = exports = function (apiList, ctrlList) {
  // clever controller logic
  return {};
};
exports['@require'] = ['api/list-blogposts', 'controller/list-blogposts'];

So I can inject different modules with the same name, or same modules with different names, a lot of flexibility there.

Seems with simple-ioc all modules should have different names, like apiListBlogposts and controllerListBlogposts in the above example.

This leads to verbosity that in a medium-sized project is not always helpful.

Am I missing something?

@joakimrapp
Copy link
Collaborator

I'll look in to your suggestion, a bit swamped at the moment, but it doesn't sound that bad :)

One question though, how would the "different modules with the same name" work when the container identifies modules by names, maybe I misunderstand you?

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

No branches or pull requests

2 participants