MCPcopy Create free account
hub / github.com/TanStack/db / flushPendingChanges

Method flushPendingChanges

packages/db/src/query/effect.ts:761–784  ·  view source on GitHub ↗

Classify accumulated changes into DeltaEvents and invoke the callback

()

Source from the content-addressed store, hash-verified

759
760 /** Classify accumulated changes into DeltaEvents and invoke the callback */
761 private flushPendingChanges(): void {
762 if (this.pendingChanges.size === 0) return
763
764 // If skipInitial and initial load isn't complete yet, discard
765 if (this.skipInitial && !this.initialLoadComplete) {
766 this.pendingChanges = new Map()
767 return
768 }
769
770 const events: Array<DeltaEvent<TRow, TKey>> = []
771
772 for (const [key, changes] of this.pendingChanges) {
773 const event = classifyDelta<TRow, TKey>(key as TKey, changes)
774 if (event) {
775 events.push(event)
776 }
777 }
778
779 this.pendingChanges = new Map()
780
781 if (events.length > 0) {
782 this.onBatchProcessed(events)
783 }
784 }
785
786 /** Check if all source collections are in the ready state */
787 private checkAllCollectionsReady(): boolean {

Callers 2

runGraphMethod · 0.95
maybeRunGraphMethod · 0.80

Calls 1

classifyDeltaFunction · 0.85

Tested by

no test coverage detected