Shareable container implementation#198
Conversation
|
Please review @theKashey and @anacierdem 🙏🙏🙏🙏 (hopefully for the last time) |
|
Long story short:
And I really like how |
|
anacierdem
left a comment
There was a problem hiding this comment.
Liked the new API, I definitely think this is the correct direction as well. Also it was a good opportunity for me to study the code a little. Let me know if I am off on any of my comments, would like to understand the library better.
Thank you @albertogasparin for this bold change!
| }; | ||
|
|
||
| // eslint-disable-next-line no-unreachable | ||
| return createFunctionContainer({ |
There was a problem hiding this comment.
Yes, wanna test it in product behind FF, so this makes it easier
| ? store === override.Store | ||
| : store.containedBy === FunctionContainer; | ||
|
|
||
| function FunctionContainer({ children, scope, isGlobal, ...restProps }) { |
There was a problem hiding this comment.
This indeed introduces a construct similar to that of #146 Even though I am not certain how it will turn out right now, feels like the correct direction.
|
Addressed the PR comments and published the reworked docs |
|
Quite solid work, you've invested much more effort than I anticipated, but the outcome is also proportionally better 🎉 |
|
Last moment question - should handle behaviour for stores marked to be
Why:
If there was something to shout at me earlier - that would save 3 dev days 😉 |
Yes, that will come right after this PR. Didn't wanna overload this one too much because it already has lots of changes 😄 |
Evolution after #196 discussion.
We are inverting the Container / Store relationship. Now stores can link to a container via
containedByso containers can be shared across stores. Container actions also move to thecreateStoreAPI (underhandlers) so there is no need to distinguish between stores in a multi store containment situation.This also makes Containers extremely lightweight, as they can be imported anywhere in the tree without risking importing actions and other Store specific implementations. It will also enable erroring whenever a store should be
containedBybut it is not (#190).From:
to
We will still support the old API, which now becomes a way to provide overrides in specific situations (eg tests). So if a store has
containedBybut the subscribers render under a Container that was created explicitly with that store argument, such container will own the state even if it was not the one specified incontainedBy.The risks of having both styles in a codebase should be minimal, and we can soft push to adopt the new pattern by promoting it by default on the docs and progressively move to it via linting and codemods.