Repeatedly executes a task forever until cancelled. This is an infinite loop that only stops via cancellation.
The async task to execute repeatedly.
Optional
Cancellable configuration options.
A cancellable handle that never resolves (only rejects on cancellation).
const handle = forever(async (token) => { await token.sleep(1000); console.log("tick");});// Stop after 5 secondssetTimeout(() => handle.cancel(), 5000); Copy
const handle = forever(async (token) => { await token.sleep(1000); console.log("tick");});// Stop after 5 secondssetTimeout(() => handle.cancel(), 5000);
Repeatedly executes a task forever until cancelled. This is an infinite loop that only stops via cancellation.