Search e01
One query across the encyclopedia, books, dictionary, papers, Wikidata and the developer library. Every hit carries its source.
6 results across 6 corpora for AsyncDisposableStack.prototype.adopt().
Developer library 6
AsyncDisposableStack
The **`AsyncDisposableStack`** object represents a stack of [async disposers](/docs/Web/JavaScript/Reference/Statements/await_using) to run when the stack itself is disposed. Disposer functions are executed in reverse order of registration, with strong error handling guarantees. Calling its `move()` method will transfer responsibility for calling the current registered disposers to a new `AsyncDisposableStack` and pr
AsyncDisposableStack.prototype.defer()
The **`defer()`** method of AsyncDisposableStack instances takes a callback function to be called and awaited when the stack is disposed. See DisposableStack.prototype.defer() for general information about the `defer()` method. ## Syntax ```js-nolint defer(onDispose) ``` ### Parameters - `onDispose` - : A function that will be called when the stack is disposed. The function receives no arguments and can return
AsyncDisposableStack.prototype.adopt()
The **`adopt()`** method of AsyncDisposableStack instances registers a value that doesn't implement the async disposable protocol to the stack by providing a custom disposer function. See DisposableStack.prototype.adopt() for general information about the `adopt()` method. ## Syntax ```js-nolint adopt(value, onDispose) ``` ### Parameters - `value` - : Any value to be registered to the stack. - `onDispose` -
AsyncDisposableStack.prototype.use()
The **`use()`** method of AsyncDisposableStack instances registers a value that implements the [async disposable protocol](/docs/Web/JavaScript/Guide/Resource_management) to the stack. See DisposableStack.prototype.use() for general information about the `use()` method. ## Syntax ```js-nolint use(value) ``` ### Parameters - `value` - : The value to register to the stack. Must either contain a `[Symbol.asyncDis
AsyncDisposableStack.prototype.disposeAsync()
The **`disposeAsync()`** method of AsyncDisposableStack instances disposes this stack by calling all disposers registered to it in reverse order of registration, awaiting for each one's completion before calling the next one. If the stack is already disposed, this method does nothing. It performs the same action as `await using disposer = new AsyncDisposableStack()` at scope exit. It can be used if you need to clean
DisposableStack
features/ecmascript/explicit-resource-management) - [JavaScript resource management](/docs/Web/JavaScript/Guide/Resource_management) - Symbol.dispose - using - AsyncDisposableStack