Documentation / @ripl/core / Task
Class: Task<TResult>
Defined in: packages/core/src/task/index.ts:42
A cancellable promise with AbortController integration, supporting abort callbacks and chaining.
Extends
Promise<TResult>
Extended by
Type Parameters
| Type Parameter | Default type |
|---|---|
TResult | void |
Constructors
Constructor
new Task<
TResult>(executor,controller?):Task<TResult>
Defined in: packages/core/src/task/index.ts:47
Parameters
| Parameter | Type |
|---|---|
executor | TaskExecutor<TResult> |
controller | AbortController |
Returns
Task<TResult>
Overrides
Promise<TResult>.constructor
Properties
| Property | Modifier | Type | Inherited from | Defined in |
|---|---|---|---|---|
[toStringTag] | readonly | string | Task.[toStringTag] | node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:174 |
[species] | readonly | PromiseConstructor | Promise.[species] | node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:178 |
Accessors
hasAborted
Get Signature
get hasAborted():
boolean
Defined in: packages/core/src/task/index.ts:106
Whether this task has already been aborted.
Returns
boolean
signal
Get Signature
get signal():
AbortSignal
Defined in: packages/core/src/task/index.ts:101
The AbortSignal associated with this task's controller.
Returns
AbortSignal
Methods
abort()
abort(
reason?):this
Defined in: packages/core/src/task/index.ts:111
Aborts the task with an optional reason, triggering all registered abort callbacks.
Parameters
| Parameter | Type |
|---|---|
reason? | unknown |
Returns
this
catch()
catch<
TResult>(onrejected?):Promise<TResult|TResult>
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1562
Attaches a callback for only the rejection of the Promise.
Type Parameters
| Type Parameter | Default type |
|---|---|
TResult | never |
Parameters
| Parameter | Type | Description |
|---|---|---|
onrejected? | ((reason) => TResult | PromiseLike<TResult>) | null | The callback to execute when the Promise is rejected. |
Returns
Promise<TResult | TResult>
A Promise for the completion of the callback.
Inherited from
Promise.catch
finally()
finally(
onfinally?):Promise<TResult>
Defined in: node_modules/typescript/lib/lib.es2018.promise.d.ts:27
Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.
Parameters
| Parameter | Type | Description |
|---|---|---|
onfinally? | (() => void) | null | The callback to execute when the Promise is settled (fulfilled or rejected). |
Returns
Promise<TResult>
A Promise for the completion of the callback.
Inherited from
Promise.finally
then()
then<
TResult1,TResult2>(onfulfilled?,onrejected?):Promise<TResult1|TResult2>
Defined in: node_modules/typescript/lib/lib.es5.d.ts:1555
Attaches callbacks for the resolution and/or rejection of the Promise.
Type Parameters
| Type Parameter | Default type |
|---|---|
TResult1 | TResult |
TResult2 | never |
Parameters
| Parameter | Type | Description |
|---|---|---|
onfulfilled? | ((value) => TResult1 | PromiseLike<TResult1>) | null | The callback to execute when the Promise is resolved. |
onrejected? | ((reason) => TResult2 | PromiseLike<TResult2>) | null | The callback to execute when the Promise is rejected. |
Returns
Promise<TResult1 | TResult2>
A Promise for the completion of which ever callback is executed.
Inherited from
Promise.then
all()
Call Signature
staticall<T>(values):Promise<Awaited<T>[]>
Defined in: node_modules/typescript/lib/lib.es2015.iterable.d.ts:253
Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
values | Iterable<T | PromiseLike<T>> | An iterable of Promises. |
Returns
Promise<Awaited<T>[]>
A new Promise.
Inherited from
Promise.all
Call Signature
staticall<T>(values):Promise<{ -readonly [P in string | number | symbol]: Awaited<T[P]> }>
Defined in: node_modules/typescript/lib/lib.es2015.promise.d.ts:37
Creates a Promise that is resolved with an array of results when all of the provided Promises resolve, or rejected when any Promise is rejected.
Type Parameters
| Type Parameter |
|---|
T extends [] | readonly unknown[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
values | T | An array of Promises. |
Returns
Promise<{ -readonly [P in string | number | symbol]: Awaited<T[P]> }>
A new Promise.
Inherited from
Promise.all
allSettled()
Call Signature
staticallSettled<T>(values):Promise<{ -readonly [P in string | number | symbol]: PromiseSettledResult<Awaited<T[P]>> }>
Defined in: node_modules/typescript/lib/lib.es2020.promise.d.ts:36
Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.
Type Parameters
| Type Parameter |
|---|
T extends [] | readonly unknown[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
values | T | An array of Promises. |
Returns
Promise<{ -readonly [P in string | number | symbol]: PromiseSettledResult<Awaited<T[P]>> }>
A new Promise.
Inherited from
Promise.allSettled
Call Signature
staticallSettled<T>(values):Promise<PromiseSettledResult<Awaited<T>>[]>
Defined in: node_modules/typescript/lib/lib.es2020.promise.d.ts:44
Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
values | Iterable<T | PromiseLike<T>> | An array of Promises. |
Returns
Promise<PromiseSettledResult<Awaited<T>>[]>
A new Promise.
Inherited from
Promise.allSettled
any()
Call Signature
staticany<T>(values):Promise<Awaited<T[number]>>
Defined in: node_modules/typescript/lib/lib.es2021.promise.d.ts:38
The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.
Type Parameters
| Type Parameter |
|---|
T extends [] | readonly unknown[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
values | T | An array or iterable of Promises. |
Returns
Promise<Awaited<T[number]>>
A new Promise.
Inherited from
Promise.any
Call Signature
staticany<T>(values):Promise<Awaited<T>>
Defined in: node_modules/typescript/lib/lib.es2021.promise.d.ts:45
The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
values | Iterable<T | PromiseLike<T>> | An array or iterable of Promises. |
Returns
Promise<Awaited<T>>
A new Promise.
Inherited from
Promise.any
race()
Call Signature
staticrace<T>(values):Promise<Awaited<T>>
Defined in: node_modules/typescript/lib/lib.es2015.iterable.d.ts:261
Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
values | Iterable<T | PromiseLike<T>> | An iterable of Promises. |
Returns
Promise<Awaited<T>>
A new Promise.
Inherited from
Promise.race
Call Signature
staticrace<T>(values):Promise<Awaited<T[number]>>
Defined in: node_modules/typescript/lib/lib.es2015.promise.d.ts:48
Creates a Promise that is resolved or rejected when any of the provided Promises are resolved or rejected.
Type Parameters
| Type Parameter |
|---|
T extends [] | readonly unknown[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
values | T | An array of Promises. |
Returns
Promise<Awaited<T[number]>>
A new Promise.
Inherited from
Promise.race
reject()
staticreject<T>(reason?):Promise<T>
Defined in: node_modules/typescript/lib/lib.es2015.promise.d.ts:58
Creates a new rejected promise for the provided reason.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | never |
Parameters
| Parameter | Type | Description |
|---|---|---|
reason? | any | The reason the promise was rejected. |
Returns
Promise<T>
A new rejected Promise.
Inherited from
Promise.reject
resolve()
Call Signature
staticresolve():Promise<void>
Defined in: node_modules/typescript/lib/lib.es2015.promise.d.ts:64
Creates a new resolved promise.
Returns
Promise<void>
A resolved promise.
Inherited from
Promise.resolve
Call Signature
staticresolve<T>(value):Promise<Awaited<T>>
Defined in: node_modules/typescript/lib/lib.es2015.promise.d.ts:70
Creates a new resolved promise for the provided value.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
value | T | A promise. |
Returns
Promise<Awaited<T>>
A promise whose internal state matches the provided promise.
Inherited from
Promise.resolve
Call Signature
staticresolve<T>(value):Promise<Awaited<T>>
Defined in: node_modules/typescript/lib/lib.es2015.promise.d.ts:76
Creates a new resolved promise for the provided value.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
value | T | PromiseLike<T> | A promise. |
Returns
Promise<Awaited<T>>
A promise whose internal state matches the provided promise.
Inherited from
Promise.resolve
try()
statictry<T,U>(callbackFn, ...args):Promise<Awaited<T>>
Defined in: node_modules/typescript/lib/lib.es2025.promise.d.ts:31
Takes a callback of any kind (returns or throws, synchronously or asynchronously) and wraps its result in a Promise.
Type Parameters
| Type Parameter |
|---|
T |
U extends unknown[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
callbackFn | (...args) => T | PromiseLike<T> | A function that is called synchronously. It can do anything: either return a value, throw an error, or return a promise. |
...args | U | Additional arguments, that will be passed to the callback. |
Returns
Promise<Awaited<T>>
A Promise that is:
- Already fulfilled, if the callback synchronously returns a value.
- Already rejected, if the callback synchronously throws an error.
- Asynchronously fulfilled or rejected, if the callback returns a promise.
Inherited from
Promise.try
withResolvers()
staticwithResolvers<T>():PromiseWithResolvers<T>
Defined in: node_modules/typescript/lib/lib.es2024.promise.d.ts:32
Creates a new Promise and returns it in an object, along with its resolve and reject functions.
Type Parameters
| Type Parameter |
|---|
T |
Returns
PromiseWithResolvers<T>
An object with the properties promise, resolve, and reject.
const { promise, resolve, reject } = Promise.withResolvers<T>();Inherited from
Promise.withResolvers