Changelog #39

·

Task Library & more tasks

Matt Aitken

Matt Aitken

CEO, Trigger.dev

Image for Task Library & more tasks

Task Library

We now have a dedicated docs page called Task Library where you can easily find and learn about built-in tasks to use in your jobs, like waitForEvent() or backgroundFetch():

image

New Tasks

We also have a few new tasks that we've added to the library:

io.backgroundPoll()

image

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:

const result = await io.backgroundPoll<{ foo: string }>("🔃", {
url: "https://example.com/api/endpoint",
interval: 10, // every 10 seconds
timeout: 300, // stop polling after 5 minutes
responseFilter: {
// stop polling once this filter matches
status: [200],
body: {
status: ["SUCCESS"],
},
},
});

We even display each poll request in the run dashboard:

image

See our reference docs to learn more.

io.sendEvents()

image

io.sendEvents() allows you to send multiple events at a time:

await io.sendEvents("send-events", [
{
name: "new.user",
payload: {
userId: "u_12345",
},
},
{
name: "new.user",
payload: {
userId: "u_67890",
},
},
]);

See our reference docs to learn more.

io.random()

io.random() is identical to Math.random() when called without options but ensures your random numbers are not regenerated on resume or retry. It will return a pseudo-random floating-point number between optional min (default: 0, inclusive) and max (default: 1, exclusive). Can optionally round to the nearest integer.

How to update

The trigger.dev/* packages are now at v2.2.6. You can update using the following command:

npx @trigger.dev/cli@latest update

Ready to start building?

Build and deploy your first task in 3 minutes.

Get started now

We only collect analytics cookies so we can improve your experience.

Privacy policy