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.svelte

24 lines
458 B

<script>
import { tick } from 'svelte';
export let snapshots = [];
let count = 0;
let buttons = [];
function increment() {
count += 1;
log();
}
function log() {
snapshots.push(`before ${buttons[0].textContent}`);
tick().then(() => {
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>