new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

TanStack Query · Reference · all subjects

queriesobserver

6 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

QueriesObserver constructor and subscribe method

QueriesObserver is a class that can be used to observe multiple queries. It takes two arguments: a queryClient and an array of query option objects. The subscribe method accepts a callback function that receives results and returns an unsubscribe function to stop listening for updates.

QueriesObserver options match useQueries

The options for QueriesObserver are exactly the same as those of the useQueries hook.

QueriesObserver example usage

Example of observing multiple queries with QueriesObserver: const observer = new QueriesObserver(queryClient, [ { queryKey: ['post', 1], queryFn: fetchPost }, { queryKey: ['post', 2], queryFn: fetchPost }, ]) const unsubscribe = observer.subscribe((result) => { console.log(result) unsubscribe() })

QueryObserver constructor and subscribe method

QueryObserver is instantiated with new QueryObserver(queryClient, options). It has a subscribe method that takes a callback function. The callback receives a result object. The subscribe method returns an unsubscribe function that can be called to stop observing.

QueryObserver options same as useQuery

The options passed to QueryObserver are exactly the same as the options for the useQuery hook.

QueryObserver usage example

const observer = new QueryObserver(queryClient, { queryKey: ['posts'] }) const unsubscribe = observer.subscribe((result) => { console.log(result) unsubscribe() }) This example shows how to create a QueryObserver for the 'posts' query key, subscribe to its updates, and unsubscribe after receiving the first result.

Give your agent this brain