You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/packages/svelte/tests/runtime-runes/samples/props-derived-teardown/main.svelte

26 lines
459 B

<script>
import { SvelteSet } from 'svelte/reactivity'
import Teardown from './Teardown.svelte'
class Test {
originalIds = $state.raw([1, 2, 3])
ids = $derived(new SvelteSet(this.originalIds))
}
let show = $state(true)
const test = new Test()
function callback() {
test.ids.delete(2)
}
</script>
<button onclick={() => (show = !show)}>click</button>
{#if show}
<Teardown {callback} />
{/if}
{#each test.ids as id}
<div>{id}</div>
{/each}