Skip to main content

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]>;
ParameterTypeDescription
actionkeyof StoreActionsAction name (e.g. "add-card")
dataStoreActions[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>
  • 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