Event handlers are defined as functions.
Event handlers are registered as listener with on:
followed by the event name.
Register event listeners on HTML elements and Svelte components with the on:
directive.
In this example, we'll call alert('Good job!')
when a task is completed.
Event handlers are defined as functions.
Event handlers are registered as listener with on:
followed by the event name.
Components can dispatch events to parent components with Svelte's built-in createEventDispatcher
helper.
Provide an event name and data for your component to dispatch.
Create a handler for your custom event.
Register your handler as a listener for your custom event.
Svelte also supports event modifiers on native DOM events.
Further reading on this topic.