getSharedAbortSignal
The signal of the app-wide shared ResettableAbortController.
Call it at the start of each operation. Never cache it, or the operation after the first abort starts already aborted.
Import:
import { getSharedAbortSignal } from '@mnaoumov/typescript-lib/abort-controller';Example:
const abortSignal = getSharedAbortSignal();for (const url of urls) { abortSignal.throwIfAborted(); await fetch(url, { signal: abortSignal });}Signature:
function getSharedAbortSignal(): AbortSignalReturns: AbortSignal — The AbortSignal of the shared ResettableAbortController.
Example:
const abortSignal = getSharedAbortSignal();for (const url of urls) { abortSignal.throwIfAborted(); await fetch(url, { signal: abortSignal });}Links to this page: