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/documentation/examples/21-miscellaneous/02-immutable-data/ImmutableTodo.svelte

31 lines
449 B

<svelte:options immutable />
<script>
import { afterUpdate } from 'svelte';
import flash from './flash.js';
export let todo;
let btn;
afterUpdate(() => {
flash(btn);
});
</script>
<!-- the text will flash red whenever
the `todo` object changes -->
<button bind:this={btn} on:click>
{todo.done ? '👍' : ''}
{todo.text}
</button>
<style>
button {
cursor: pointer;
border:none;
background:none;
font-size:14px;
}
</style>