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/packages/svelte/tests/runtime-runes/samples/dynamic-event-handler-3/main.svelte

28 lines
476 B

<script>
import Button from './Button.svelte';
let count = $state(0);
let d = $state(1);
function create_handler() {
const change = d;
console.log(`creating handler (${change})`);
return function increment() {
count += change;
console.log(count);
};
}
</script>
<button on:click={() => (d += 1)}>increase d ({d})</button>
<button on:click={create_handler()}>
clicks: {count}
</button>
<Button on:click={create_handler()}>
clicks: {count}
</Button>