Deferred live queries: let the sync adapter report an already-held subset (isSubsetLoaded) so a remounted page renders on its first frame
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 48/100
- Type d'issue
- Fonctionnalité
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- typescript
- Domaine
- backend
Piste de recherche
Read types.ts, collection/sync.ts, and collection/subscription.ts, focusing on CollectionSubscription.startSubsetDemand and the deferred acquisition path. First inspect the existing subset loading tests and run the relevant @tanstack/db tests. Done means the optional hook publishes rows for an already-held deferred subset while preserving the three stated loading and acquisition cases.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Since #2060, a live query with no subscriber or preload yet keeps its on-demand source demands detached. An ordered window over such a source stays unpublished until its acquisitions settle. That's the right default: render work starts no provider work.
It also means a page that mounts again (back navigation, a tab switch, a route that unmounts and remounts) draws loading on its first frame, even when the source still holds every row of that window. The supported way around it is to preload() the same live query in a route loader. That only works when the loader can name the exact query. When the query depends on who is viewing, on settings, or on other queries, the first frame is empty, the page renders short, and the browser's scroll restoration clamps to the top.
The sync adapter often knows that a subset is already held. Its loadSubset would answer true at once, but core can't ask without breaking #2060's rule.
Proposal: an optional, side-effect-free hook on the sync result:
type SyncConfigRes = {
loadSubset?: LoadSubsetFn
unloadSubset?: UnloadSubsetFn
/**
* Whether the Collection already holds every row of the subset `options`
* names, so `loadSubset` would answer `true` at once. A local check: no
* provider work, no state change.
*/
isSubsetLoaded?: (options: LoadSubsetOptions) => boolean
}
In CollectionSubscription.startSubsetDemand, the deferred on-demand branch still records the demand as detached, exactly as now. When isSubsetLoaded(requestOptions) returns true, it returns true instead of the pending initial result, so the window publishes from rows already installed. Acquisition still starts on resumeDeferredAcquisition(), so provider sync, revalidation and live updates are unchanged. Without the hook, nothing changes.
We have this implemented on 0.15.2: about 30 lines across types.ts, collection/sync.ts and collection/subscription.ts. A test covers three cases:
- a deferred window over a held subset is
readywith its rows before it subscribes, and still callsloadSubsetafter subscribing; - without the hook, it stays
loading; - for a subset that isn't held, it stays
loading.
The full @tanstack/db suite passes. Our InstantDB adapter answers the hook from its ready subscriptions and held prefixes, and it fixed back-navigation scroll restoration for us. Happy to open a PR.
- Langage dominant
- TypeScript
- Étoiles
- 3.9k
- Forks
- 277
- Merge moyen
- 18 h 7 min
- PR mergées (30 j)
- 228
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de TanStack/db
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 1-2 jours Accessibilité débutants 48/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 1-2 jours Accessibilité débutants 45/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de TanStack/db
Issues similaires
-
[Bug]: REST API URL starting with "http" but no scheme (e.g. httpbin.org/get) is not given an http:// prefixPeut-être pris @ItsDeadlyProgrammer l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
appsmithorg/appsmith#42471 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
ehmpathy/rhachet-roles-bhrain#705 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
Status: Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
mermaid-js/mermaid#8546 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
braintrustdata/braintrust-sdk-javascript#2659 ·
Les mainteneurs répondent en général sous 1 jour