cancellableDelay
cancellableDelay(
delayInSeconds
): [Promise
<unknown
>, () =>void
]
delay
Parameters
• delayInSeconds: number
= 0
Returns
[Promise
<unknown
>, () => void
]
Usage
const [delay, cancel] = cancellableDelay(5);
// Assume checkCondition is some function that returns a boolean if (checkCondition()) { cancel(); // Cancel the delay if the condition is met } else { await delay; // Otherwise, wait for the delay to elapse }
// Continue with the rest of your code…