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.

Available actions​

Every action has a built-in store handler.

ActionPayloadDescription
add-card{ card; edit?; id?; before?; after? }Adds a card. edit: true opens the editor on it. before or after sets the position; before wins.
update-card{ id; card }Patches a card
move-card{ id; column?; swimlane?; before? }Moves a card to another column, or to another lane with swimlane (PRO). before: null moves it to the end
duplicate-card{ id; card?; edit? }Clones a card; card overrides fields on the copy
delete-card{ id }Removes a card
select-card{ id }Opens the editor on a card, or closes it with id: null
update-column{ id; column }Patches a column config (label, css, collapsed, ...)
add-column{ column; id?; before? }Adds a column
delete-column{ id }Removes a column
move-column{ id; before? }Reorders columns
add-swimlane{ swimlane; id?; before? }Adds a swimlane (PRO)
update-swimlane{ id; swimlane }Patches a swimlane config (PRO)
move-swimlane{ id; before? }Reorders swimlanes (PRO)
delete-swimlane{ id }Removes a swimlane (PRO)
filter-cards{ filter?; tag? }Applies or clears a filter; tag keeps several filters separate
sort-cards{ sort? }Applies or clears a sort
request-data{ id }Asks the host for a column's cards (PRO)
provide-data{ id?; cards }Upserts cards; with id, marks that column as loaded
export-dataExportConfigExports the board to PDF, PNG, or a custom transport (PRO)
undo / redo{}Steps through history; needs history: true (PRO)

Example​

import { useRef } from "react";
import { Kanban } from "@svar-ui/react-kanban";

function App() {
const apiRef = useRef(null);

return (
<>
<Kanban ref={apiRef} cards={cards} columns={columns} />

<button onClick={() => apiRef.current.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