* Tracks a load promise for isLoadingSubset state. * @internal This is for internal coordination (e.g., live-query glue code), not for general use.
(promise: Promise<void>)
| 443 | * @internal This is for internal coordination (e.g., live-query glue code), not for general use. |
| 444 | */ |
| 445 | public trackLoadPromise(promise: Promise<void>): void { |
| 446 | const loadingStarting = !this.isLoadingSubset |
| 447 | this.pendingLoadSubsetPromises.add(promise) |
| 448 | |
| 449 | if (loadingStarting) { |
| 450 | this._events.emit(`loadingSubset:change`, { |
| 451 | type: `loadingSubset:change`, |
| 452 | collection: this.collection, |
| 453 | isLoadingSubset: true, |
| 454 | previousIsLoadingSubset: false, |
| 455 | loadingSubsetTransition: `start`, |
| 456 | }) |
| 457 | } |
| 458 | |
| 459 | promise.finally(() => { |
| 460 | const loadingEnding = |
| 461 | this.pendingLoadSubsetPromises.size === 1 && |
| 462 | this.pendingLoadSubsetPromises.has(promise) |
| 463 | this.pendingLoadSubsetPromises.delete(promise) |
| 464 | |
| 465 | if (loadingEnding) { |
| 466 | this._events.emit(`loadingSubset:change`, { |
| 467 | type: `loadingSubset:change`, |
| 468 | collection: this.collection, |
| 469 | isLoadingSubset: false, |
| 470 | previousIsLoadingSubset: true, |
| 471 | loadingSubsetTransition: `end`, |
| 472 | }) |
| 473 | } |
| 474 | }) |
| 475 | } |
| 476 | |
| 477 | /** |
| 478 | * Requests the sync layer to load more data. |
no test coverage detected