You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Combines several AbortSignal instances into a signal which will be aborted as soon as any of the given signals are.
import{AggregateSignal}from"@toebean/signals";constac=newAbortController();constaggregateSignal=newAggregateSignal(ac.signal,someOtherSignal);// passing an aggregate signal into an awaitable, abortable call:awaitdoSomeAbortableAction({signal: aggregateSignal.signal});// determining which of the original signals was aborted first:switch(aggregateSignal.abortedSignal){caseac.signal:
// do stuffbreak;// etc...}
TimeoutSignal
Creates an AbortSignal which will timeout after a given number of milliseconds, using setTimeout under the hood.
import{AggregateSignal}from"@toebean/signals";consttimeoutSignal=newTimeoutSignal(200);// creates an AbortSignal which will abort in 200ms// passing a timeout signal into an awaitable, abortable call:awaitdoSomeAbortableAction({signal: timeoutSignal.signal});// If for whatever reason you need to clear the underlying timeout of the TimeoutSignal, you can:clearTimeout(timeoutSignal.timeout);
isAbortSignal
A TypeScript type guard for checking whether a given object is an AbortSignal.
import{isAbortSignal}from"@toebean/signals";if(isAbortSignal(someObject)){// within this block, someObject is typed as an AbortSignalconsole.log(someObejct.aborted);}