ngneat/query

How to use persistQueryClient?

MaximilianLloyd opened this issue · 3 comments

Hi. I was wondering how you can use the persistQueryClient functionality with this?

As in React, I guess. Provide the function what it needs.

Ok, this is what i currently have. But it doesn't seem to be working

const queryClient = new QueryClient({
  defaultOptions: {
    queries: {
      staleTime: Infinity,
      refetchOnWindowFocus: false
    }
  }
});

const persister = createSyncStoragePersister({
  storage: window.localStorage,
  serialize: (data) => compress(JSON.stringify(data)),
  deserialize: (data) => JSON.parse(decompress(data))
});

persistQueryClient({ queryClient, persister: persister , maxAge: Infinity });


persistQueryClientRestore({ queryClient, persister: persister });

and

providers: [
    provideQueryClient(queryClient)
]

Can you provide a stackblitz, please?