Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ninety-bears-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@powersync/react': patch
---

Allow using `db.syncStream()` instances in `useQuery` hooks.
2 changes: 1 addition & 1 deletion packages/react/src/hooks/streams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface UseSyncStreamOptions extends SyncStreamSubscribeOptions {
* Parameters for the stream subscription. A single stream can have multiple subscriptions with different parameter
* sets.
*/
parameters?: Record<string, any>;
parameters?: Record<string, any> | null;
}

/**
Expand Down
9 changes: 9 additions & 0 deletions packages/react/tests/streams.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ describe('stream hooks', () => {
expect(currentStreams()).toStrictEqual([]);
});

it('useQuery can take syncStream instance', async () => {
const { result } = renderHook(() => useQuery('SELECT 1', [], { streams: [db.syncStream('a')] }), {
wrapper: testWrapper
});

// Not resolving the subscription.
await waitFor(() => expect(result.current.data).toHaveLength(1), { timeout: 1000, interval: 100 });
});

it('useQuery waiting on stream', async () => {
const { result } = renderHook(
() => useQuery('SELECT 1', [], { streams: [{ name: 'a', waitForStream: true }] }),
Expand Down