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