Creates an event dispatcher that can be used to dispatch component events.
Event dispatchers are functions that can take two arguments: name and detail.
Component events created with createEventDispatcher create a
CustomEvent.
These events do not bubble.
The detail argument corresponds to the CustomEvent.detail
property and can contain any type of data.
The event dispatcher can be typed to narrow the allowed event names and the type of the detail argument:
constdispatch = createEventDispatcher<{ loaded: never; // does not take a detail argument change: string; // takes a detail argument of type string, which is required optional: number | null; // takes an optional detail argument of type number }>();
Creates an event dispatcher that can be used to dispatch component events. Event dispatchers are functions that can take two arguments:
name
anddetail
.Component events created with
createEventDispatcher
create a CustomEvent. These events do not bubble. Thedetail
argument corresponds to the CustomEvent.detail property and can contain any type of data.The event dispatcher can be typed to narrow the allowed event names and the type of the
detail
argument:https://svelte.dev/docs/svelte#createeventdispatcher