Skip to content

Commit f339b41

Browse files
committed
Added some basic Defer migration details for CRON
1 parent ae40ce3 commit f339b41

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

docs/v3/migration-defer.mdx

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ This guide highlights the differences and should help you migrate your project.
1111

1212
Here are some features you might be using in Defer that are coming this month to v3:
1313

14-
- [Scheduled tasks (including CRON)](/v3/tasks-scheduled) will be available in mid-April.
1514
- Triggering a task with a delay (like `assignOptions` delay in Defer) will be available soon – there is [an alternative](#delay) you can use for now.
1615

1716
You can view the full feature matrix [here](/v3/feature-matrix).
@@ -256,6 +255,36 @@ export async function runLongRunningTask() {
256255

257256
#### Example 2: A CRON task
258257

259-
<Warning>
260-
"Scheduled" tasks will be available by mid-April. This will allow you to replace Defer CRON tasks.
261-
</Warning>
258+
We call these [scheduled tasks](/v3/tasks-scheduled) in Trigger.dev.
259+
260+
In Defer you might have a function like this:
261+
262+
```ts
263+
import { defer } from "@defer/client";
264+
265+
async function sendMondayNewletter() {
266+
// business logic here
267+
}
268+
269+
export default defer.cron(sendMondayNewletter, "0 0 * * 1");
270+
```
271+
272+
In Trigger.dev the task looks like this:
273+
274+
```ts
275+
import { schedules } from "@trigger.dev/sdk/v3";
276+
277+
//this task will run when any of the attached schedules trigger
278+
export const sendMondayNewletter = schedules.task({
279+
id: "send-monday-newsletter",
280+
run: async (payload) => {
281+
// business logic here
282+
},
283+
});
284+
```
285+
286+
Then you need to attach a schedule to the task, either using the dashboard or in your code. You can attach unlimited schedules to a task.
287+
288+
<Card title="Attaching schedules" icon="clock" href="/v3/tasks-scheduled">
289+
How to attach a schedule to a task
290+
</Card>

0 commit comments

Comments
 (0)