-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix: no data duplication in reactive Set/Map #11200
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
Conversation
|
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.
Thanks for this!
This breaks |
I was trying to see how #11222 could be fixed without reintroducing data duplication but unless we want to reimplement each one of the methods by hand we need the data in the "faux" Set since we are invoking methods on it. The simple fix would be to revert this and introduce data duplication again. |
Yes, all methods need to be implemented. The problem with that is that it will also break if the prototypes of any of the builtins are changed. |
I'll take look at this. We do already redefine the methods in |
The point is that that's exactly the bug: in init we are redefining the methods to actually call super.methodname in the set instance but since that instance has no values they are empty. We could reimplement those methods but that adds code to maintain, probably less performant code in those operations (since is not native) and no forward compatibility for a small memory gain. |
But obviously feel free to try and report back if you succeed 😁 |
Yeah, I get that. I feel like there is a way to use native implementation without duplication. Also this is only applicable to By the way, I think map not having those methods is actually the main issue here. Since we currently model set with map keys and there are no such methods for map keys. Maybe we can find a different approach to model the data? |
I've to investigate a bit further as I didn't check if |
Svelte 5 rewrite
Data in reactive Set/Map was unnecessarily passed back to the super class. That would mean storing the same thing twice. This PR addresses this problem and adds a couple of tests to ensure the implementation is correct.
We have discussed this earlier on Discord: https://discord.com/channels/457912077277855764/1153350350158450758/1227898085087248434, where @trueadm suggested I made a PR.
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint