The type of result the task will produce. A type of never
means the activity never produces a value, but instead will run until it is
cleaned up, e.g. due to being canceled, ended with an error, etc.
ReadonlyendRelease all resources held by the task or context.
Arrange for all cleanup functions and result consumers added to the context (via release, must, do, etc.) be called in the appropriate order. When the call to end() returns, all child tasks will have been notified of their cancellation. (But not all of their cleanups or result consumers may have run yet, in the event that another task's end() is in progress when this method is called.)
If any cleanup callbacks throw exceptions, they're sent to
root.asyncThrow(), which by default converts them to unhandled promise
rejections. This ensures all of the callbacks will be run, even if one
throws an error. (And none of the errors will be missed.)
Note: this method is a bound function, so you can pass it as a callback to another task, event source, etc.
Invoke a callback with the result.
Callbacks are executed in FIFO order after any cleanups for the producing task have run, and before any asynchronous (Promise) callbacks run. You should only use this (and other Future methods) to obtain a result, not to perform cleanups. (That's what .Context.must() and .Context.release() callbacks are for.)
Invoke a callback if the producing task is canceled.
This is shorthand for a .do() callback that checks for a cancellation, so it uses the same relative order and runs in the same group as other .do callbacks.
The callback run on cancellation
Invoke a callback upon result if the result is an error.
This is shorthand for a .do() callback that checks for an error and marks it handled, so it uses the same relative order and runs in the same group as other .do callbacks.
A callback that will receive the error
Invoke a callback upon result if the result is a success/value.
This is shorthand for a .do() callback that checks for a success/value result, so it uses the same relative order and runs in the same group as other .do callbacks.
A callback that will receive the value
Readonly[toAttaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.
Optionalonfinally: (() => void) | nullThe callback to execute when the Promise is settled (fulfilled or rejected).
A Promise for the completion of the callback.
A task is a cancellable future: i.e. something that produces an async result, but whose work can be aborted.