examples/solid/playground
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
TanStack Solid Query Playground Example#
A todo list with adjustable staleTime, gcTime and error rate, to see how queries and mutations react to them.
How it works#
src/services/todos/queries.tsdefinestodosQueries.list(filter)andtodosQueries.detail(id)withqueryOptions, keyed under['todos', 'list']and['todos', 'detail', id], andtodosMutations.create()andupdate()withmutationOptions.src/services/todos/api.tssimulates a server in memory. Every call waits a random time betweenserverConfig.queryTimeMinandserverConfig.queryTimeMaxand fails atserverConfig.errorRate.src/index.tsxbinds the inputs toserverConfigand callsqueryClient.setDefaultOptionswith the chosenstaleTimeandgcTimefrom acreateEffect. Each filter list reads its todos withuseQuery, and "Force Refetch All" callsqueryClient.invalidateQueries().- The
EditTodoandAddTodocomponents insrc/index.tsxrun the mutations withuseMutation. On success they invalidatetodosQueries.lists(), and saving an edit also writes the result into the detail query withqueryClient.setQueryData.
To run this example:
npm installnpm run dev