Skip to content

onAbort

Adds an abort listener to an abort signal and calls the callback if the abort signal is already aborted.

Import:

import { onAbort } from '@mnaoumov/typescript-lib/abort-controller';

Signature:

function onAbort(abortSignal: AbortSignal, callback: (abortSignal: AbortSignal) => void): Disposable

Parameters:

Parameter Type Description
abortSignal AbortSignal The abort signal to add the listener to.
callback (abortSignal: AbortSignal) => void The callback to call when the abort signal aborts.

Returns: Disposable — A Disposable that removes the abort listener when disposed, for use with using.