Use the toggle attribute of the Todo components

pull/5124/head
lukasmoellerch 5 years ago
parent db0b3b3dfc
commit 393ac4cfe6

@ -29,10 +29,10 @@
<h2>Immutable</h2> <h2>Immutable</h2>
{#each todos as todo} {#each todos as todo}
<ImmutableTodo {todo} on:click="{() => toggle(todo.id)}"/> <ImmutableTodo {todo} toggle={() => toggle(todo.id)}/>
{/each} {/each}
<h2>Mutable</h2> <h2>Mutable</h2>
{#each todos as todo} {#each todos as todo}
<MutableTodo {todo} on:click="{() => toggle(todo.id)}"/> <MutableTodo {todo} toggle={() => toggle(todo.id)}/>
{/each} {/each}

@ -23,6 +23,6 @@
<!-- the text will flash red whenever <!-- the text will flash red whenever
the `todo` object changes --> the `todo` object changes -->
<div bind:this={div} on:click> <div bind:this={div} on:click={toggle}>
{todo.done ? '👍': ''} {todo.text} {todo.done ? '👍': ''} {todo.text}
</div> </div>

@ -21,6 +21,6 @@
<!-- the text will flash red whenever <!-- the text will flash red whenever
the `todo` object changes --> the `todo` object changes -->
<div bind:this={div} on:click> <div bind:this={div} on:click={toggle}>
{todo.done ? '👍': ''} {todo.text} {todo.done ? '👍': ''} {todo.text}
</div> </div>

Loading…
Cancel
Save