Create a DisposableStore that manages Disposers and IDisposables.
A DisposableStore is also a Disposer, which means it can be the dispose method of an IDisposable.
dispose
A DisposableStore is also an IDisposable, which means it can be managed by another DisposableStore.
import { type IDisposable, disposableStore } from "@wopjs/disposable";class A implements IDisposable { dispose = disposableStore() constructor() { this.dispose.add(...); }}class B implements IDisposable { dispose = disposableStore() a = this.dispose.add(new A()) constructor() { this.dispose.add(...); }}const b = new B();b.dispose(); // dispose both `b` and `b.a`.
A disposable store.
Optional
Optional array of DisposableTypes added to the store.
Create a DisposableStore that manages Disposers and IDisposables.
A DisposableStore is also a Disposer, which means it can be the
dispose
method of an IDisposable.A DisposableStore is also an IDisposable, which means it can be managed by another DisposableStore.
Example
Returns
A disposable store.