Skip to content

Svelte 5: make maps and sets reactive #9761

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

Closed
Rich-Harris opened this issue Dec 4, 2023 · 3 comments
Closed

Svelte 5: make maps and sets reactive #9761

Rich-Harris opened this issue Dec 4, 2023 · 3 comments

Comments

@Rich-Harris
Copy link
Member

Rich-Harris commented Dec 4, 2023

Describe the problem

It would be nice if these worked...

<script>
  let numbers = $state(new Set([1, 2, 3]));
</script>

<button onclick={() => numbers.add(numbers.size + 1}>add</button>
<button onclick={() => numbers.clear()}>clear</button>

<p>{numbers.size}</p>
<p>{[...numbers].join(', ')}</p>
{#each numbers as n}<p>{n}</p></each}

...and the same for Map.

Describe the proposed solution

Intercept method gets on proxied maps/sets

Alternatives considered

Subclasses. Yuck

Importance

nice to have

@Rich-Harris Rich-Harris added this to the 5.0 milestone Dec 4, 2023
@enyo
Copy link

enyo commented Dec 4, 2023

I think it's meant to say

let numbers = $state(new Set([1, 2, 3]));

(just adding this note so nobody is confused when finding this issue :) )

@Rich-Harris
Copy link
Member Author

oops, good catch 😆 fixed

@trueadm
Copy link
Contributor

trueadm commented Feb 16, 2024

We're going to be doing #10263.

@trueadm trueadm closed this as completed Feb 16, 2024
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

3 participants