You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .cursor/rules/writing-tasks.mdc
-22Lines changed: 0 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -431,28 +431,6 @@ export async function POST(request: Request) {
431
431
}
432
432
```
433
433
434
-
### tasks.triggerAndPoll()
435
-
436
-
Triggers a task and polls until completion. Not recommended for web requests as it blocks until the run completes. Consider using Realtime docs for better alternatives.
437
-
438
-
```ts
439
-
import { tasks } from "@trigger.dev/sdk/v3";
440
-
import type { emailSequence } from "~/trigger/emails";
441
-
442
-
export async function POST(request: Request) {
443
-
const data = await request.json();
444
-
const result = await tasks.triggerAndPoll<typeof emailSequence>(
445
-
"email-sequence",
446
-
{
447
-
to: data.email,
448
-
name: data.name,
449
-
},
450
-
{ pollIntervalMs: 5000 }
451
-
);
452
-
return Response.json(result);
453
-
}
454
-
```
455
-
456
434
### batch.trigger()
457
435
458
436
Triggers multiple runs of different tasks at once, useful when you need to execute multiple tasks simultaneously.
|`tasks.trigger()`| Triggers a task and returns a handle you can use to fetch and manage the run. |[Docs](#tasks-trigger)|
13
-
|`tasks.batchTrigger()`| Triggers a single task in a batch and returns a handle you can use to fetch and manage the runs. |[Docs](#tasks-batchtrigger)|
14
-
|`tasks.triggerAndPoll()`| Triggers a task and then polls the run until it’s complete. |[Docs](#tasks-triggerandpoll)|
15
-
|`batch.trigger()`| Similar to `tasks.batchTrigger` but allows running multiple different tasks |[Docs](#batch-trigger)|
|`tasks.trigger()`| Triggers a task and returns a handle you can use to fetch and manage the run. |[Docs](#tasks-trigger)|
13
+
|`tasks.batchTrigger()`| Triggers a single task in a batch and returns a handle you can use to fetch and manage the runs. |[Docs](#tasks-batchtrigger)|
14
+
|`batch.trigger()`| Similar to `tasks.batchTrigger` but allows running multiple different tasks |[Docs](#batch-trigger)|
16
15
17
16
Trigger tasks **from inside a another task**:
18
17
@@ -162,40 +161,6 @@ export async function POST(request: Request) {
162
161
}
163
162
```
164
163
165
-
### tasks.triggerAndPoll()
166
-
167
-
Triggers a single run of a task with the payload you pass in, and any options you specify, and then polls the run until it's complete.
168
-
169
-
<Warning>
170
-
We don't recommend using `triggerAndPoll()`, especially inside a web request, as it will block the
171
-
request until the run is complete. Please see our [Realtime docs](/realtime) for a better way to
// Pass the task type to `triggerAndPoll()` as a generic argument, giving you full type checking
185
-
const result =awaittasks.triggerAndPoll<typeofemailSequence>(
186
-
"email-sequence",
187
-
{
188
-
to: data.email,
189
-
name: data.name,
190
-
},
191
-
{ pollIntervalMs: 5000 }
192
-
);
193
-
194
-
//return a success response with the result
195
-
returnResponse.json(result);
196
-
}
197
-
```
198
-
199
164
### batch.trigger()
200
165
201
166
Triggers multiple runs of different tasks with the payloads you pass in, and any options you specify. This is useful when you need to trigger multiple tasks at once.
0 commit comments