Skip to content

Commit 0b7b362

Browse files
committed
Renamed useBatch to useRealtimeBatch
1 parent da08e50 commit 0b7b362

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

.changeset/honest-trains-burn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/react-hooks": patch
3+
---
4+
5+
useBatch renamed to useRealtimeBatch

packages/react-hooks/src/hooks/useRealtimeBatch.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,21 @@ import { AnyTask, InferRunTypes, TaskRunShape } from "@trigger.dev/core/v3";
44
import { useEffect, useState } from "react";
55
import { useApiClient } from "./useApiClient.js";
66

7-
export function useBatch<TTask extends AnyTask>(batchId: string) {
7+
/**
8+
* hook to subscribe to realtime updates of a batch of task runs.
9+
*
10+
* @template TTask - The type of the task.
11+
* @param {string} batchId - The unique identifier of the batch to subscribe to.
12+
* @returns {{ runs: TaskRunShape<TTask>[], error: Error | null }} An object containing the current state of the runs and any error encountered.
13+
*
14+
* @example
15+
*
16+
* ```ts
17+
* import type { myTask } from './path/to/task';
18+
* const { runs, error } = useRealtimeBatch<typeof myTask>('batch-id-123');
19+
* ```
20+
*/
21+
export function useRealtimeBatch<TTask extends AnyTask>(batchId: string) {
822
const [runShapes, setRunShapes] = useState<TaskRunShape<TTask>[]>([]);
923
const [error, setError] = useState<Error | null>(null);
1024
const apiClient = useApiClient();

0 commit comments

Comments
 (0)