Custom Events with createEventDispatcher
Emit typed custom events from child components for parent to handle.
Why Custom Events
Child components communicate up by dispatching custom events the parent listens for.
Import the Dispatcher
Import createEventDispatcher from svelte and create one inside your script.
<script>
import { createEventDispatcher } from "svelte";
const dispatch = createEventDispatcher();
</script>All lessons in this course
- on:click on:input on:submit
- Event Modifiers: preventDefault stopPropagation once
- Custom Events with createEventDispatcher
- Forwarding Events with on:click