-
-
Notifications
You must be signed in to change notification settings - Fork 260
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
feat(utils): add proxy set #325
Conversation
- `initialValues` signature match native set - use `Array.from` during instantiation - wrap object in proxy when calling `has` - `toJSON` match native set behavior
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/pmndrs/valtio/2PWcViXEBHPsgp67XunpWC6ZTbua |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 353f0cf:
|
That's a very nice idea! |
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.
Once again, this is cool. Look forward to merging.
#321 is merged. Please merge (or rebase from) the main branch.
- use type instead of interface - update initialValues signature - fix object check - use splice instead of reassignment to avoid creating a new proxy - add tests for proxySet internal
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.
Getting better and better.
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.
LGTM
This is very good. It doesn't look so magical. (Not easy for everyone though, like how this
works for snapshots.)
Thanks for your work!
Amazing, do you want me to add an example before we merge? I'm trying to figure out a good use case(a simple one) for using Set. I thought first about the todo but most of the operations relies on the todo id which makes sense |
You can work on examples in a separate PR. Can you add a short section in readme? |
Sure, no problem I'll do this later today when I'm back. I've also pushed another commit to remove the |
Added a tiny readme section let me know if it's enough |
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.
sure, let's merge this and ship it.
I created a new PR as I rebased from fix(core): expose canProxy in handler #321. Below is the output of the tests that are generated. I can of course add more if needed.
I was thinking to add an example as well inside the example folder
todo-with-proxySet
or whatever the name. Let me know if you think it's worth it