exec
Dispatches an action through the event bus. The action flows through interceptors first, then the store's default handler, then on handlers, and finally the component's on{action} prop callback.
Usage
exec<A extends keyof StoreActions>(
action: A,
data: StoreActions[A]
): Promise<StoreActions[A]>;
| Parameter | Type | Description |
|---|---|---|
action | keyof StoreActions | Action name (e.g. "add-card") |
data | StoreActions[A] | Action payload matching the action |
Returns a Promise that resolves with the (possibly mutated) payload after all handlers have run.
Example
<script>
import { Kanban } from "@svar-ui/svelte-kanban";
let api;
</script>
<Kanban bind:this={api} {cards} {columns} />
<button onclick={() => api.exec("add-card", {
card: { label: "New task" },
edit: true,
})}>
Add Card
</button>
Related
- Actions overview — all actions dispatchable through exec
- on — register a handler that fires after exec processes an action
- intercept — register a pre-handler that can cancel an action