detach
Removes a handler or interceptor that was registered with api.on or api.intercept using a tag. Call this to clean up event subscriptions when they're no longer needed.
Usage
detach(tag: number | string | symbol): void;
| Parameter | Type | Description |
|---|---|---|
tag | number | string | symbol | The tag assigned when registering the handler via the config parameter of on or intercept |
Example
Register a handler with a tag, then remove it later:
<script>
import { Kanban } from "@svar-uisvelte-kanban";
let api;
function attach(a) {
api = a;
api.on("update-card", (ev) => {
console.log("card updated", ev.id);
}, { tag: "logger" });
}
function cleanup() {
api.detach("logger");
}
</script>
<Kanban {cards} {columns} init={attach} />
<button onclick={cleanup}>Remove logger</button>