fjorgemota / jimple

Just a dependency injection container to NodeJS and to the browser using new ES6 features
MIT License
75 stars 12 forks source link

aliases #1

Closed pawelbaranski closed 6 years ago

pawelbaranski commented 8 years ago

Hi,

I know it is not a feature of Silex, but still, this is very useful one. Care to merge this PR :) ?

fjorgemota commented 8 years ago

Hey! Thanks for the PR. I'm thinking in some problems related to this approach:

container.set("session.mysql", function(c) {
  // ....
});
container.alias("session", "session.mysql");
container.set("session", function() {
 // ....
});

A exception is emitted on the set of the session, after adding the alias, because well, the key already exists. Should we ignore alias in that case or not?

container.alias("alias_1", "alias_2");
container.alias("alias_2", "alias_1");

Infinite loop, again?

container.alias("session", "session.mysql")
var session = container.raw("session");

I think that session will not contain the original session.mysql function, right?

container.set("user_repository", function(c) {
    return c.get("user_repository."+c.get("user_repository.type"));
});

Or similar, not? Note that is for a similar reason that this exactly feature was not added to the original Pimple (see silexphp/Pimple#115): seems to be too simple to the developer to enable a behavior similar to that of an alias with flexibility (it can manage the alias like it want to) and ease of use.

What do you think?

pawelbaranski commented 8 years ago

This are some valid questions, I will address them as soon as I can

fjorgemota commented 8 years ago

Hello!

Any new updates?

By the way.

Two new points: