Create a DisposableOne that manages a single Disposer or IDisposable.
A DisposableOne is also a Disposer, which means it can be the dispose method of an IDisposable.
dispose
Optional
Optional DisposableType to set as the initial value.
The created DisposableOne.
import { type IDisposable, DisposableOne } from "@wopjs/disposable";const dispose = disposableOne();dispose.set(() => console.log("hello"));dispose.set(() => console.log("world")); // prints "hello"dispose.set(() => console.log("foo")); // prints "world"dispose(); // prints "foo" Copy
import { type IDisposable, DisposableOne } from "@wopjs/disposable";const dispose = disposableOne();dispose.set(() => console.log("hello"));dispose.set(() => console.log("world")); // prints "hello"dispose.set(() => console.log("foo")); // prints "world"dispose(); // prints "foo"
Create a DisposableOne that manages a single Disposer or IDisposable.
A DisposableOne is also a Disposer, which means it can be the
disposemethod of an IDisposable.