QueryObserver

· abundance's blog


QueryObserver #

The QueryObserver can be used to observe and switch between queries.

1const observer = new QueryObserver(queryClient, { queryKey: ['posts'] })
2
3const unsubscribe = observer.subscribe((result) => {
4  console.log(result)
5  unsubscribe()
6})

Options

The options for the QueryObserver are exactly the same as those of useQuery.