examples/solid/batching
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
TanStack Solid Query Batching Example#
Several components request characters at the same time, and an async batcher from TanStack Pacer combines those requests into one.
How it works#
src/services/characters/queries.tsdefinescharactersQueries.detail(id)withqueryOptions, keyed by['characters', 'detail', id]with a 1-minutestaleTime.src/services/characters/api.tsadds eachgetCharacter(id)call to anAsyncBatcherfrom TanStack Pacer withwait: 0. The batcher sends one Rick and Morty API request for all collected ids and resolves each query's promise with its own character.src/index.tsxpasses onecharactersQueries.detail(id)per id touseQueries, so each character is still a separate query in the cache even though the network request is shared.
To run this example:
npm installnpm run dev