query icon indicating copy to clipboard operation
query copied to clipboard

Should ngneat/query Cache Pages Instead of Fetching on Each Pagination Click?

Open jon9090 opened this issue 1 year ago • 0 comments

Which @ngneat/query-* package(s) are the source of the bug?

query

Is this a regression?

No

Description

I cloned this repository to learn about ngneat/query with pagination.

When I navigated to the pagination example, I clicked "next page" a few times and then went back using the "previous" button. I noticed that each time I clicked a button, ngneat/query invoked the fetchProjects function again. This means that in a real application, it would make a server request every time.

You can see in the picture that each time fetchProjects is called, it logs to the console:

function fetchProjects(nextPage: number) {
  console.log('in fetchProjects: ', nextPage);
  const page = nextPage || 0;
  const pageSize = 10;
  ...

Is this how pagination is supposed to work? Isn't ngneat/query supposed to cache the pages it has already fetched?

image

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in

No response

Anything else?

No response

Do you want to create a pull request?

No

jon9090 avatar May 22 '24 08:05 jon9090