Tasks
Run a task at a precise time, with automatic retries
The Tasks API is an easy way to create, delete and list tasks that will be run at a given date and automatically retried.
The Tasks API is currently subject to change, however, any changes we make to the API will not affect your Repeat until it is published again.
As such, all of the below methods are available under
env.unstable.tasks
Signature
interface Tasks { add( data: string | JSON, options?: { id?: string, runAt?: string } ): Promise<{ id: string; }>; delete(id: string): Promise<boolean>; list(): Promise<{ id: string; }[]>; }
Methods
- add(data, options?: { id?, runAt? }) →
Promise<{ id: string }>
The add
method allows you to create a new task which the task
handler for this Repeat will handle, accepting the following parameters.
- delete(id) →
Promise<boolean>
Thedelete
method allows you to remove the task associated with a givenid
. The returnedboolean
indicates if the delete was successful.
- list() →
Promise<{ id: string }[]>
The list
method returns a list of tasks yet to run for this Repeat.
Last updated on December 6, 2022