File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
content/tutorial/01-svelte/04-logic/05-keyed-each-blocks Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 1
1
<script >
2
+ import { onDestroy } from ' svelte' ;
3
+
2
4
const emojis = {
3
5
apple: ' 🍎' ,
4
6
banana: ' 🍌' ,
12
14
13
15
// ...but the "emoji" variable is fixed upon initialisation of the component
14
16
const emoji = emojis[name];
17
+
18
+ // observe in the console which entry is removed
19
+ onDestroy (() => {
20
+ console .log (' thing destroyed: ' + name);
21
+ });
15
22
</script >
16
23
17
24
<p >
Original file line number Diff line number Diff line change 1
1
<script >
2
+ import { onDestroy } from ' svelte' ;
3
+
2
4
const emojis = {
3
5
apple: ' 🍎' ,
4
6
banana: ' 🍌' ,
12
14
13
15
// ...but the "emoji" variable is fixed upon initialisation of the component
14
16
const emoji = emojis[name];
17
+
18
+ // observe in the console which entry is removed
19
+ onDestroy (() => {
20
+ console .log (' thing destroyed: ' + name);
21
+ });
15
22
</script >
16
23
17
24
<p >
You can’t perform that action at this time.
0 commit comments