-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
each for new Set([]) #3225
Comments
Spread it into an array with |
Thanks @Conduitry but I think I explained myself wrong. What I'd like to do is something like: let selectedPlayers = new Set()
function addOrRemove(playerID) {
if (selectedPlayers.has(playerID)) {
selectedPlayers.delete(playerID)
} else {
selectedPlayers.add(playerID)
}
} I don't know how to use it with: {#if selectedPlayers.size}
{#each selectedPlayers as player}
{player}
{/each}
{/if} |
The same approach will work: {#if selectedPlayers.size}
{#each [ ...selectedPlayers ] as player}
{player}
{/each}
{/if} |
@pngwn I'm sorry it doesn't work, REPL: https://svelte.dev/repl/38b796562e024e6890a0949af85627ba?version=3.6.7 |
You need to follow the reactivity rules, there is no assignment here so an update will not be triggered. |
Oh. Thanks.
|
Has the same effect, yeah. |
Is it possible to iterate over
new Set([])
with e.g.{#each ...}
?What is the recommended method?
The text was updated successfully, but these errors were encountered: