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

Method stateWhenReady

packages/db/src/collection/index.ts:835–843  ·  view source on GitHub ↗

* Gets the current state of the collection as a Map, but only resolves when data is available * Waits for the first sync commit to complete before resolving * * @returns Promise that resolves to a Map containing all items in the collection

()

Source from the content-addressed store, hash-verified

833 * @returns Promise that resolves to a Map containing all items in the collection
834 */
835 stateWhenReady(): Promise<Map<TKey, WithVirtualProps<TOutput, TKey>>> {
836 // If we already have data or collection is ready, resolve immediately
837 if (this.size > 0 || this.isReady()) {
838 return Promise.resolve(this.state)
839 }
840
841 // Use preload to ensure the collection starts loading, then return the state
842 return this.preload().then(() => this.state)
843 }
844
845 /**
846 * Gets the current state of the collection as an Array

Callers 15

persisted.test.tsFile · 0.80
query.test.tsFile · 0.80
createTestStateFunction · 0.80
rxdb.test.tsFile · 0.80
executeSmokeTestFunction · 0.80
load-hooks.test.tsFile · 0.80
powersync.test.tsFile · 0.80

Calls 2

isReadyMethod · 0.95
preloadMethod · 0.95

Tested by 5

createTestStateFunction · 0.64
createOrderByTestsFunction · 0.64
createOrderByBugTestsFunction · 0.64