Closed jtwigg closed 7 years ago
@ilyapuchka So far so good with that change. Thanks for the speedy response. I'd be open to writing a litany of unit tests on your behalf. I have pretty clear ideas about how I'd like to lay our our dependency graph.
@ilyapuchka Adding comments and tests to your PR.
How can I create two isolated child containers whereby I have
a) A root container with registered singleton services b) Two child containers which are independent of each other and may even have similar & conflicting registrations.
The children have access to the Root, but not each other. The Root doesn't have access to the children.
This is in the vain of Daggers Subcomponents and Guices Private Module or the always hideous Swinject Container Hierarchy
An example of this would be where I have two flows, one for logged in and one for unlogged in users.
I think the behavior changed with bug https://github.com/AliSoftware/Dip/issues/148 : Prior to this, the test failed differently; The containers were isolated but the SerivceA was created twice.
Having read the Collaboration code, both unlogged and logged in are bound together to be collaborators since it recurses through the dependencies->dependancies.
loggedIn.collaborate(...)
lines, it fails because it can't find the serviceThe option to go directly to rootContainer.resolve() instead works...
loggedIn.register(.singleton) { Password(text: "1234", service:rootContainer.resolve()) }
but is not very desirable because it means when I setup my containers, I have to have extra knowledge about how the dep was registered and with what container, somewhat defeating the purpose of Dip.Thoughts?