Skip to content

Function: createAbortGroup()

ts
function createAbortGroup(): {
  abortAll: () => void;
  add: (controller?) => AbortSignal;
};

Creates a group of AbortControllers that can all be aborted at once. 创建一组可统一取消的 AbortController。

Returns

ts
{
  abortAll: () => void;
  add: (controller?) => AbortSignal;
}

abortAll

ts
abortAll: () => void;

Returns

void

add

ts
add: (controller?) => AbortSignal;

Parameters

ParameterType
controller?AbortController

Returns

AbortSignal

Example

ts
const group = createAbortGroup()
const signal = group.add()
signal.aborted // => false
group.abortAll()
signal.aborted // => true

Since

1.0.0

Released under the MIT License.