Skip to main content

init

Callback fired once after the first store initialization, before the first render effect runs. Use it to grab the API reference, attach data providers, register interceptors, or wire up 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-uisvelte-kanban";

let api;
</script>

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

Attach a REST data provider during initialization:

<script>
import { Kanban, RestDataProvider } from "@svar-uisvelte-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-uisvelte-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)