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/test/runtime/samples/lifecycle-next-tick/main.html

24 lines
459 B

<script>
import { nextTick } from 'svelte';
export let snapshots = [];
let count = 0;
let buttons = [];
function increment() {
count += 1;
log();
}
function log() {
snapshots.push(`before ${buttons[0].textContent}`);
nextTick(() => {
snapshots.push(`after ${buttons[0].textContent}`);
});
}
</script>
<button bind:this={buttons[0]} on:click={increment}>{count}</button>
<button bind:this={buttons[1]} on:click={log}>{count}</button>