Skip to content

Commit 56d29e0

Browse files
committed
docs: update Keyed Each Blocks tutorial
align with sveltejs/svelte#8188
1 parent f565e2b commit 56d29e0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

content/tutorial/01-svelte/04-logic/05-keyed-each-blocks/app-a/src/lib/Thing.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script>
2+
import { onDestroy } from 'svelte';
3+
24
const emojis = {
35
apple: '🍎',
46
banana: '🍌',
@@ -12,6 +14,11 @@
1214
1315
// ...but the "emoji" variable is fixed upon initialisation of the component
1416
const emoji = emojis[name];
17+
18+
// observe in the console which entry is removed
19+
onDestroy(() => {
20+
console.log('thing destroyed: ' + name);
21+
});
1522
</script>
1623

1724
<p>

content/tutorial/01-svelte/04-logic/05-keyed-each-blocks/app-b/src/lib/Thing.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script>
2+
import { onDestroy } from 'svelte';
3+
24
const emojis = {
35
apple: '🍎',
46
banana: '🍌',
@@ -12,6 +14,11 @@
1214
1315
// ...but the "emoji" variable is fixed upon initialisation of the component
1416
const emoji = emojis[name];
17+
18+
// observe in the console which entry is removed
19+
onDestroy(() => {
20+
console.log('thing destroyed: ' + name);
21+
});
1522
</script>
1623

1724
<p>

0 commit comments

Comments
 (0)