Skip to content

Commit 347a3c6

Browse files
committed
Use the stream's requestSnapshot method
1 parent f678672 commit 347a3c6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

packages/electric-db-collection/src/electric.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ function createElectricSync<T extends Row<unknown>>(
497497
})
498498

499499
return {
500-
onLoadMore: (opts) => onLoadMore(params, opts),
500+
onLoadMore: (opts) => onLoadMore(stream, params, opts),
501501
cleanup: () => {
502502
// Unsubscribe from the stream
503503
unsubscribeStream()
@@ -512,6 +512,7 @@ function createElectricSync<T extends Row<unknown>>(
512512
}
513513

514514
async function onLoadMore<T extends Row<unknown>>(
515+
stream: ShapeStream<T>,
515516
syncParams: Parameters<SyncConfig<T>[`sync`]>[0],
516517
options: OnLoadMoreOptions
517518
) {
@@ -522,7 +523,7 @@ async function onLoadMore<T extends Row<unknown>>(
522523

523524
const snapshotParams = compileSQL<T>(options)
524525

525-
const snapshot = await requestSnapshot(snapshotParams)
526+
const snapshot = await stream.requestSnapshot(snapshotParams)
526527

527528
begin()
528529

packages/electric-db-collection/src/sql-compiler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ function compileBasicExpression(
4848
return exp.path[0]!
4949
case `func`:
5050
return compileFunction(exp, params)
51+
default:
52+
throw new Error(`Unknown expression type`)
5153
}
5254
}
5355

0 commit comments

Comments
 (0)