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

Sharing singleton scope when deriving a new injector #81

Open
StatusReport opened this issue Dec 19, 2014 · 1 comment
Open

Sharing singleton scope when deriving a new injector #81

StatusReport opened this issue Dec 19, 2014 · 1 comment

Comments

@StatusReport
Copy link

We have a scenario where we want to derive a new injector from an existing one with additional modules when displaying a new view controller. The existing injector has singleton instances that are already cached within it, and we need to use the same instance of them in the new injector.

Currently, using withModuleOfType: will create a new injector with the same global context, but with new injection entries that will create new instances of the singletons upon request.

It makes sense to me that derives injectors will produce the same singletons of the original injector, since we want to inherit the behavior of the original injector, including its context. What do you think?

Additionally, if anyone got any idea on how to overcome this in a different, elegant way, I'd be happy to know.

@jdewind
Copy link
Contributor

jdewind commented Dec 19, 2014

I agree with this change. Singletons typically imply state and I can understand the need to keep it between modules.

I'll create a branch to implement this.

Thank 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