Deferred live queries: let the sync adapter report an already-held subset (isSubsetLoaded) so a remounted page renders on its first frame
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 48/100
- Tipo de issue
- Funcionalidade
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- typescript
- Domínio
- backend
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- TypeScript
- Estrelas
- 4k
- Forks
- 277
- Merge médio
- 18h 7min
- PRs com merge (30d)
- 228
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de TanStack/db
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 1-2 dias Facilidade para iniciantes 48/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 1-2 dias Facilidade para iniciantes 45/100
Mantenedores costumam responder em até 1 dia
Todas as issues de TanStack/db
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
awesome-dsh-plugin/awesome-dsh-plugin#9184 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
farion1231/cc-switch#8829 ·
Mantenedores costumam responder em até 1 dia
-
[core-client] Remove unused hand-maintained transport helpers after the definition-table cutoverAbertadoc-audit enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100