Skip to content

Commit fcafd82

Browse files
kevin-dpsamwillis
authored andcommitted
Use the stream's requestSnapshot method
1 parent c17226e commit fcafd82

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
@@ -419,7 +419,7 @@ function createElectricSync<T extends Row<unknown>>(
419419
})
420420

421421
return {
422-
onLoadMore: (opts) => onLoadMore(params, opts),
422+
onLoadMore: (opts) => onLoadMore(stream, params, opts),
423423
cleanup: () => {
424424
// Unsubscribe from the stream
425425
unsubscribeStream()
@@ -434,6 +434,7 @@ function createElectricSync<T extends Row<unknown>>(
434434
}
435435

436436
async function onLoadMore<T extends Row<unknown>>(
437+
stream: ShapeStream<T>,
437438
syncParams: Parameters<SyncConfig<T>[`sync`]>[0],
438439
options: OnLoadMoreOptions
439440
) {
@@ -444,7 +445,7 @@ async function onLoadMore<T extends Row<unknown>>(
444445

445446
const snapshotParams = compileSQL<T>(options)
446447

447-
const snapshot = await requestSnapshot(snapshotParams)
448+
const snapshot = await stream.requestSnapshot(snapshotParams)
448449

449450
begin()
450451

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)