vovaspace / brandi

The dependency injection container powered by TypeScript.
https://brandi.js.org
ISC License
194 stars 12 forks source link

Change child container ref on parent change #30

Closed BerkliumBirb closed 1 year ago

BerkliumBirb commented 1 year ago

I don't really know how to save sate with testing-library between two renders. If you need test cases for this exact behavior let me know.

But I guess this is major api change.

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
brandi ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 19, 2023 at 6:08AM (UTC)
vovaspace commented 1 year ago

Hi! Thank you for PR!

I see that this is a more correct container extending logic but I can’t thing of a case where it’s important. Can you tell more about your case?

BerkliumBirb commented 1 year ago

Sure I can.

We have an application with following containers hierarchy:

The feature we're implementing now is introducing Offline version which means separating DAOs in another layer like so:

But here we have a problem now: when we change DAOs layer only common services layer extends and Presenters are not caused to reinitialize.

The solution we came up first with was using tags, like they intended. But it requires us double work on container construction using .when and practically limits next feature coming: multi user simultaneous work. We were planning to build multi user feature using a container-context for each user. We can introduce new tag for each user but that looks not okay from design point of view and doubles precise container building work.

So this is the fix we came up with and will be very happy to see in main version!

BerkliumBirb commented 1 year ago

@vovaspace do you need anything else from my side?