Open History to see the last commit
TanStack Lit 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)keyed by['todos', 'list', { filter }]andtodosQueries.detail(id)withqueryOptions, andtodosMutations.create()andtodosMutations.update()withmutationOptions.src/services/todos/api.tsis an in-memory todo server with a random delay and error rate set byserverConfig.getTodosreceives the query'ssignaland logs when a request is cancelled.src/main.tscallsqueryClient.setDefaultOptionsinwillUpdatewhen thestaleTimeorgcTimeinputs change, and writes the error rate and fetch times intoserverConfig. "Force Refetch All" callsqueryClient.invalidateQueries().src/todo-list.tsandsrc/edit-todo.tscallcreateQueryControllerand showfailureCountwhile retrying. Saving insrc/edit-todo.tsor adding insrc/add-todo.tswithcreateMutationControllerinvalidatestodosQueries.lists(), and saving also writes the result withsetQueryData.
To run this example:
npm installnpm run dev