setNext
Appends a handler to the end of the event bus chain so it receives every dispatched action after the built-in handlers run. This is how RestDataProvider wires itself into the kanban - it registers its REST handlers as the "next" link in the chain, forwarding card mutations to the backend automatically.
Usage
setNext(handler: any): any;
The handler is typically an object with its own action-handling methods (like the one returned by RestDataProvider). The method returns the handler that was passed in.
Example
Attaching a REST data provider:
import { useState } from "react";
import { Kanban, RestDataProvider } from "@svar-ui/react-kanban";
const url = "https://api.example.com";
const provider = new RestDataProvider(url);
function App() {
const [cards, setCards] = useState([]);
async function init(api) {
api.setNext(provider);
setCards(await provider.getData());
}
return <Kanban cards={cards} columns={columns} init={init} />;
}
export default App;
Related
- Working with server - REST persistence and dynamic loading
- RestDataProvider - the built-in REST provider wired via setNext
- init - callback where setNext is typically called