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

support API for subscribeWithSelector #2

Closed
himself65 opened this issue Mar 4, 2022 · 3 comments
Closed

support API for subscribeWithSelector #2

himself65 opened this issue Mar 4, 2022 · 3 comments

Comments

@himself65
Copy link

Refs: pmndrs/zustand#603

@Tom-Julux Tom-Julux pinned this issue Mar 8, 2022
@Tom-Julux
Copy link
Owner

Thanks for opening the issue.

From what I found there are two possible ways to handle this:

  1. We remove the selector here

This would result in the synchronisation across tabs happening whenever any value of the store changes. Obviously this would be completely overkill and unnecessary. But we could adopt this behavior so all properties of a store are synchronized, chancing the usage example in the README from share("count", useStore)to share(useStore)�.

This would probably make migration to the new version the easiest and maybe guide the user to create separate stores for synchronized and non-synchronized stores. I liked the old API and having both types of properties alongside each other, but forcing a separation of the two might make sense.

  1. We make use of the new middleware

In this case the new version would be incompatible with older versions of zustand, but I guess this could work without any API changes, so I would tend towards this.

If there aren’t any other comments until the end of march, I will move forward with implementing option 2.

Sincerely, Tom

@himself65
Copy link
Author

Thank u so much for finding out the solution

@Tom-Julux
Copy link
Owner

A little ahead of my self-set schedule, but I found the time to write the little note and guide on this issue to the readme here.

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