MCPcopy Index your code
hub / github.com/TanStack/db / start

Function start

packages/powersync-db-collection/src/powersync.ts:433–464  ·  view source on GitHub ↗
(afterOnChangeRegistered?: () => Promise<void>)

Source from the content-addressed store, hash-verified

431
432 // The sync function needs to be synchronous.
433 async function start(afterOnChangeRegistered?: () => Promise<void>) {
434 database.logger.info(
435 `Sync is starting for ${viewName} into ${trackedTableName}`,
436 )
437 database.onChangeWithCallback(
438 {
439 onChange: async () => {
440 await flushDiffRecords()
441 },
442 },
443 {
444 signal: abortController.signal,
445 triggerImmediate: false,
446 tables: [trackedTableName],
447 },
448 )
449
450 await afterOnChangeRegistered?.()
451
452 // If the abort controller was aborted while processing the request above
453 if (abortController.signal.aborted) {
454 await disposeTracking?.()
455 } else {
456 abortController.signal.addEventListener(
457 `abort`,
458 async () => {
459 await disposeTracking?.()
460 },
461 { once: true },
462 )
463 }
464 }
465
466 // Eager mode.
467 // Registers a diff trigger for the entire table.

Callers 2

runEagerSyncFunction · 0.70
runOnDemandSyncFunction · 0.70

Calls 2

flushDiffRecordsFunction · 0.85
addEventListenerMethod · 0.45

Tested by

no test coverage detected