@@ -400,19 +400,22 @@ export class CollectionSubscription
400400 }
401401
402402 /**
403- * Sends a snapshot that fulfills the `where` clause and all rows are bigger or equal to the cursor.
404- * Requires a range index to be set with `setOrderByIndex` prior to calling this method.
405- * It uses that range index to load the items in the order of the index.
403+ * Loads rows from the local collection in sorted order using the BTree index.
404+ *
405+ * Uses the BTree index (set via `setOrderByIndex`) to iterate through the local
406+ * collection's data in sorted order, starting from the cursor position (`minValues`).
407+ * Also triggers an async `loadSubset` call to fetch more data from the sync layer
408+ * (e.g., Electric backend) if needed.
406409 *
407410 * For multi-column orderBy:
408- * - Uses first value from `minValues` for LOCAL index operations (wide bounds, ensures no missed rows)
409- * - Uses all `minValues` to build a precise composite cursor for SYNC layer loadSubset
411+ * - Uses first value from `minValues` for BTree index operations (wide bounds, ensures no missed rows)
412+ * - Uses all `minValues` to build a precise composite cursor for sync layer loadSubset
410413 *
411- * Note 1: it may load more rows than the provided LIMIT because it loads all values equal to the first cursor value + limit values greater.
412- * This is needed to ensure that it does not accidentally skip duplicate values when the limit falls in the middle of some duplicated values .
413- * Note 2: it does not send keys that have already been sent before .
414+ * Note 1: May load more rows than `limit` because it includes all rows equal to the
415+ * cursor value. This prevents skipping duplicates when limit falls mid-duplicates .
416+ * Note 2: Skips keys that have already been sent to prevent duplicates .
414417 *
415- * @returns true if local data was found and sent , false if the local index was exhausted
418+ * @returns true if local data was found, false if no more matching rows exist locally
416419 */
417420 requestLimitedSnapshot ( {
418421 orderBy,
@@ -635,12 +638,8 @@ export class CollectionSubscription
635638 this . loadedSubsets . push ( loadOptions )
636639 this . trackLoadSubsetPromise ( syncResult )
637640
638- // Return whether local data was found and iteration completed normally.
639- // Return false if:
640- // - No local data was found (index exhausted)
641- // - Iteration limit was hit (abnormal exit)
642- // Either case signals that the caller should stop trying to load more.
643- // The async loadSubset may still return data later.
641+ // Return true if we found and sent local data, false otherwise.
642+ // The async loadSubset call may still fetch data from the backend.
644643 return changes . length > 0 && ! hitIterationLimit
645644 }
646645
0 commit comments