Interface Action<Element, Parameter, Attributes>
Type Parameters
- Element = HTMLElement
- Parameter = undefined
- Attributes extends Record<string, any> = Record<never, any>
- Action<Node>(...args): void | ActionReturn<Parameter, Attributes>
Type Parameters
Parameters
Returns void | ActionReturn<Parameter, Attributes>
Actions are functions that are called when an element is created. You can use this interface to type such actions. The following example defines an action that only works on
<div>
elements and optionally accepts a parameter which it has a default value for:Action<HTMLDivElement>
andAction<HTMLDivElement, undefined>
both signal that the action accepts no parameters.You can return an object with methods
update
anddestroy
from the function and type which additional attributes and events it has. See interfaceActionReturn
for more details.Docs: https://svelte.dev/docs/svelte-action