Skip to main content

init

Callback fired once after the first store initialization, before the first render effect runs. Typical uses: storing the API reference, attaching data providers, registering interceptors, and calling setNext.

Subsequent prop-driven reinitializations don't re-fire init. The callback receives the same API object exposed via bind:this.

Usage​

init?: (api: KanbanInstanceApi) => void;
  • Default: undefined

Example​

Store an API reference for later use:

<script>
import { Kanban } from "@svar-ui/svelte-kanban";

let api;
</script>

<Kanban {cards} {columns} init={a => (api = a)} />

Attach a REST data provider during initialization:

<script>
import { Kanban, RestDataProvider } from "@svar-ui/svelte-kanban";

const provider = new RestDataProvider("/api/board");
</script>

<Kanban {cards} {columns} init={api => api.setNext(provider)} />

Register an interceptor to validate cards before they're added:

<script>
import { Kanban } from "@svar-ui/svelte-kanban";
</script>

<Kanban
{cards}
{columns}
init={api => {
api.intercept("add-card", ev => {
if (!ev.card.label) return false;
});
}}
/>
  • Working with server - attaching RestDataProvider via init
  • setNext - append a handler chain (typically called from init)
  • intercept - register interceptors (typically called from init)