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

Method markReady

packages/db/src/collection/lifecycle.ts:134–159  ·  view source on GitHub ↗

* Mark the collection as ready for use * This is called by sync implementations to explicitly signal that the collection is ready, * providing a more intuitive alternative to using commits for readiness signaling * @private - Should only be called by sync implementations

()

Source from the content-addressed store, hash-verified

132 * @private - Should only be called by sync implementations
133 */
134 public markReady(): void {
135 this.validateStatusTransition(this.status, `ready`)
136 // Can transition to ready from loading state
137 if (this.status === `loading`) {
138 this.setStatus(`ready`, true)
139
140 // Call any registered first ready callbacks (only on first time becoming ready)
141 if (!this.hasBeenReady) {
142 this.hasBeenReady = true
143
144 // Also mark as having received first commit for backwards compatibility
145 if (!this.hasReceivedFirstCommit) {
146 this.hasReceivedFirstCommit = true
147 }
148
149 const callbacks = [...this.onFirstReadyCallbacks]
150 this.onFirstReadyCallbacks = []
151 callbacks.forEach((callback) => callback())
152 }
153 // Notify dependents when markReady is called, after status is set
154 // This ensures live queries get notified when their dependencies become ready
155 if (this.changes.changeSubscriptions.size > 0) {
156 this.changes.emitEmptyReadyEvent()
157 }
158 }
159 }
160
161 /**
162 * Start the garbage collection timer

Callers 15

createWrappedSyncConfigFunction · 0.80
createLoopbackSyncConfigFunction · 0.80
startSyncMethod · 0.80
effect.test.tsFile · 0.80
collection.test.tsFile · 0.80
mutationFnFunction · 0.80
createReadyCollectionFunction · 0.80
createJoinTestsFunction · 0.80

Calls 4

setStatusMethod · 0.95
emitEmptyReadyEventMethod · 0.80
forEachMethod · 0.45

Tested by 4

mutationFnFunction · 0.64
createReadyCollectionFunction · 0.64
createJoinTestsFunction · 0.64
createSyncCollectionFunction · 0.64