Type Alias: Cleanup
API / @xmachines/play-dom-router / Cleanup
type Cleanup = () => void & { [Key in DisposeKey]: () => void };Defined in: play/src/disposable.ts:66
The release of a subscription. A caller runs it, or a scope releases it.
The type is a function AND a Disposable, so one value serves both forms. A caller
that holds the release in a field and runs it from a teardown keeps that code. A
caller inside one scope writes using and writes no teardown at all:
// The explicit form. It stays correct.const stop = watchAtom(count, render);stop();
// The scoped form. The scope releases it, and an exception releases it too.{ using stop = watchAtom(count, render); render(count.get());}using needs Node 24 or a browser with Explicit Resource Management, and it needs
"lib": ["ESNext"] of the consumer. The publishable packages build at
target: "esnext" and pass the syntax through, so the bundler of the consumer decides
how to emit it. The Cleanup VALUE needs neither: a runtime without Symbol.dispose
still calls it as a function, and a consumer that declares a lower lib still reads
the type. See DisposeKey for the second half of that.