Skip to content

disposable

Disposable utilities for using / await using declarations.

ClassDescription
AsyncCallbackDisposableAn async disposable that executes a callback when disposed via await using (or a manual await disposable[Symbol.asyncDispose]()).
AsyncDisposableBaseAbstract base for an AsyncDisposableEx: it carries the re-dispose guard (via MultipleDisposeBehavior) and the AsyncDisposableEx.asyncDispose alias; a subclass only implements AsyncDisposableBase.performDisposeAsync.
CallbackDisposableA disposable that executes a callback when disposed.
CombineAsyncDisposableAn AsyncDisposableEx that combines multiple async disposables and disposes all of them when it is disposed.
CombineDisposableA DisposableEx that combines multiple disposables and disposes all of them when it is disposed.
DisposableBaseAbstract base for a DisposableEx: it carries the re-dispose guard (via MultipleDisposeBehavior) and the DisposableEx.dispose alias; a subclass only implements DisposableBase.performDispose.
InterfaceDescription
AsyncCallbackDisposableConstructorParamsThe parameters for constructing an AsyncCallbackDisposable.
AsyncDisposableExAn AsyncDisposable that additionally exposes a convenience AsyncDisposableEx.asyncDispose method, so a stored handle can be disposed as handle.asyncDispose() instead of the clunkier handle[Symbol.asyncDispose]().
CallbackDisposableConstructorParamsThe parameters for constructing a CallbackDisposable.
CombineAsyncDisposableConstructorParamsThe parameters for constructing a CombineAsyncDisposable.
CombineDisposableConstructorParamsThe parameters for constructing a CombineDisposable.
DisposableExA Disposable that additionally exposes a convenience DisposableEx.dispose method, so a stored handle can be disposed as handle.dispose() instead of the clunkier handle[Symbol.dispose]().
FunctionDescription
isAsyncDisposableType guard to check if an object implements the AsyncDisposable interface.
isAsyncDisposableExType guard to check if an object implements the AsyncDisposableEx interface.
isDisposableType guard to check if an object implements the Disposable interface.
isDisposableExType guard to check if an object implements the DisposableEx interface.
toAsyncDisposableExAdapts a plain AsyncDisposable into an AsyncDisposableEx by adding a convenience AsyncDisposableEx.asyncDispose method that delegates to Symbol.asyncDispose. If the object already implements AsyncDisposableEx, it is returned unchanged.
toDisposableExAdapts a plain Disposable into a DisposableEx by adding a convenience DisposableEx.dispose method that delegates to Symbol.dispose. If the object already implements DisposableEx, it is returned unchanged.
TypeDescription
AsyncDisposeCallbackA callback invoked when an AsyncCallbackDisposable is disposed.
DisposeCallbackA callback invoked when a CallbackDisposable is disposed.
EnumDescription
DisposeErrorBehaviorDetermines the error semantics of a CombineDisposable or CombineAsyncDisposable when one of its children throws while being disposed.
DisposeOrderDetermines the order in which a CombineDisposable or CombineAsyncDisposable disposes its children.
MultipleDisposeBehaviorDetermines how a CallbackDisposable or AsyncCallbackDisposable behaves when it is disposed more than once.