* 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
()
| 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 |