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

Problem with instantiating and injecting objects with prototype strategy. #2

Open
Radio opened this issue Oct 10, 2013 · 1 comment
Labels
Milestone

Comments

@Radio
Copy link

Radio commented Oct 10, 2013

If you register object with prototype strategy and then call ctx.initialize() than ctx creates not-needed instance of registered object and injects it.

But if you later get new instance manually — it w'ont be injected.

ctx.register("someOnject", SomeObject)
    .strategy(di.strategy.proto);

ctx.initialize(); // Instance of SomeObject created and injected and just lost.

var myObject = ctx.get('someObject'); // new instance of SomeObject created but not injected.

Seems like there are two problems:

  1. For proto strategy no instances should be created during initialization.
  2. New instances should be injected when getting manually after initialization.
@KutnerUri
Copy link
Contributor

I believe you need to use the .create("name", arguments) method, instead of the .get("name") method

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

No branches or pull requests

2 participants