Web APIs

AbortSignal.any()

Try the free JavaScript compiler

Create a signal that aborts when any supplied signal aborts. The result carries the first observed abort reason. Example console output: true stop.

Formal Syntax & Structure

javascript syntaxjavascript
AbortSignal.any(signals)

Parameters & Attributes

NameTypeDescription
signalsAbortSignal[]Input signals.

Return Value

AbortSignal

Combined cancellation signal.

Working Example

Example Snippetjavascript
const a=new AbortController(),b=new AbortController(); const combined=AbortSignal.any([a.signal,b.signal]); b.abort("stop"); console.log(combined.aborted,combined.reason);
JavaScript Reference