Read more about how Tasks work here.
io
object. These tasks are designed to be generic and reusable, and are a great way to get started with Trigger.dev.
You may notice that Iβm using emojis for all the cache keys below, which is totally π―% fine as
long as they are unique inside a run. Read more about how cache keys work
here
wait
This task allows you to resume executing your job after a certain amount of time has passed:
waitForRequest
You supply this task with a callback to receive a URL. When a POST request is made to that URL, the JSON body of the request becomes the task output.
The example below uses waitForRequest
to capture a Screenshot of a website using ScreenshotOne.com and passes the callback URL to the webhook URL to get notified when the screenshot is finished:
waitForEvent
This task allows you to wait for an event to be sent. To read about how events work, check out the Events documentation.
id
, name
, payload
, context
, and more.
reference docs
backgroundFetch
This task allows you to perform a fetch
request in the background, and then resume the execution of your job after the request has completed.
backgroundPoll
This task is similar to backgroundFetch
, but instead of waiting for a single request to complete, it will poll a URL until it returns a certain value.
logger
The logger object allows you to log messages to the Trigger.dev console. This is useful for debugging your jobs, or just to see whatβs going on inside your job.
context
object to the logger, which will be displayed in the console:
io.logger.debug()
io.logger.info()
io.logger.warn()
io.logger.error()
You may notice these tasks donβt include cache keys. We automatically create a cache key for you
based on the message and the log-level
store
The store object exposes several namespaced Key-Value Stores you can access inside of your Jobs. This is useful for storing small amounts of serializable data for later retrieval:
store.env
to access and store data within the Environmentstore.job
to access and store data within the Jobstore.run
to access and store data within the Run