Skip to main content

setNext

Appends a handler to the end of the event bus chain so it receives every dispatched action after the built-in handlers run. RestDataProvider uses this method to connect to the kanban: it registers its REST handlers as the "next" link in the chain and forwards card mutations to the backend.

Usage​

setNext(handler: any): any;

The handler is typically an object with its own action-handling methods (like the one returned by RestDataProvider). Returns the passed handler.

Every dispatched action passes through the chain in this order:

  1. The store applies the action.
  2. The EventBusRouter calls the matching host on{action} prop, such as onmovecard.
  3. Handlers added with setNext run in the order they were added.

Adding a handler doesn't replace the on{action} props. They keep firing before the handler. If the store rejects an action, for example a move-card to an unknown column, the action isn't forwarded: neither the on{action} props nor the setNext handlers receive it.

Example​

Attaching a REST data provider:

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

const url = "https://api.example.com";
const provider = new RestDataProvider(url);

let cards = $state([]);

async function init(api) {
api.setNext(provider);
cards = await provider.getData();
}
</script>

<Kanban {cards} {columns} {init} />