-
Notifications
You must be signed in to change notification settings - Fork 55
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
Shareable container implementation #198
Conversation
Please review @theKashey and @anacierdem 🙏🙏🙏🙏 (hopefully for the last time) |
Long story short:
And I really like how |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this here for future reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
containedBy
so containers can be shared across stores. Container actions also move to thecreateStore
API (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
containedBy
but 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
containedBy
but 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.