Skip to content

onCleanup()

Register a function that runs when the component unmounts.

function onCleanup(fn: () => void): void
ParamTypeDescription
fn() => voidCleanup function
import { component, onCleanup, div } from "@whisq/core";
const Sub = component(() => {
const sub = eventBus.subscribe(handler);
onCleanup(() => sub.unsubscribe());
return div("Listening");
});