Skip to content

delay() ​

Delay the execution of the task by a specified time.

Syntax ​

typescript
task.delay(ms: number): FuturableTask<T>

Parameters ​

ms ​

Delay in milliseconds before execution.

Examples ​

typescript
const task = FuturableTask
  .of(() => sendNotification())
  .delay(1000); // Wait 1 second before sending

await task.run();

Rate Limiting ​

typescript
const tasks = ids.map(id =>
  FuturableTask
    .of(() => fetchData(id))
    .delay(id * 100) // Stagger requests
);

See Also ​

Released under the MIT License.