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: docs/realtime/run-object.mdx
+42-10Lines changed: 42 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,13 @@ sidebarTitle: "The run object"
4
4
description: "The run object schema for Realtime subscriptions"
5
5
---
6
6
7
-
This is the run object returned by Realtime subscriptions (e.g., `runs.subscribeToRun()`).
7
+
The [run object](/realtime/run-object#the-run-object)is the main object returned by Realtime subscriptions (e.g., `runs.subscribeToRun()`). It contains all the information about the run, including the run ID, task identifier, payload, output, and more.
8
8
9
-
## Properties
9
+
Type-safety is supported for the run object, so you can infer the types of the run's payload and output. See [type-safety](#type-safety) for more information.
10
+
11
+
## The run object
12
+
13
+
### Properties
10
14
11
15
<ParamFieldpath="id"type="string"required>
12
16
The run ID.
@@ -117,20 +121,48 @@ This is the run object returned by Realtime subscriptions (e.g., `runs.subscribe
117
121
Indicates whether this is a test run.
118
122
</ParamField>
119
123
120
-
## Typesafety
124
+
## Type-safety
121
125
122
-
You can get type safety for the run's payload and output by passing your task typeto subscription functions:
126
+
You can infer the types of the run's payload and output by passing the type of the task to the `subscribeToRun` function. This will give you type-safe access to the run's payload and output.
123
127
124
128
```ts
125
-
import { runs } from"@trigger.dev/sdk/v3";
129
+
import { runs, tasks } from"@trigger.dev/sdk/v3";
126
130
importtype { myTask } from"./trigger/my-task";
127
131
128
-
forawait (const run ofruns.subscribeToRun<typeofmyTask>(runId)) {
129
-
// run.payload and run.output are now typed based on your task
0 commit comments