Open srosset81 opened 3 weeks ago
I was thinking of a use case for the exact opposite too: Ask the hook to prefetch the first say 20 items. This might be useful for example, if the inbox pages have a small number of items (some items might be hidden due to ACL constraints).
We could name that prefetch
property for example?
Ensure refetch works
Why refetch
and not fetchNextPage
?
We could name that
prefetch
property for example?
You suggest to set a prefetch
option that defines the number of pages ? With a default to 1, and the possibility to set it to 0 or more than 1 ? In that case, pagesToPrefetch
could be more explicit.
Why
refetch
and notfetchNextPage
?
The react-query doc says to use refetch
if we don't enable the automatic query. Not sure if fetchNextPage
work. I was thinking about maybe returning it as fetch
when we use the fetchOnMount: false
option.
You suggest to set a
prefetch
option that defines the number of pages ?
I was rather thinking of prefetching a certain number of items so that we can ensure that a page is filled with a sufficient number of items?
Why
refetch
and notfetchNextPage
?The react-query doc says to use
refetch
if we don't enable the automatic query. Not sure iffetchNextPage
work. I was thinking about maybe returning it asfetch
when we use thefetchOnMount: false
option.
I think this might be a bit unintuitive to have two different approaches, depending on how many items were preloaded?
I was rather thinking of prefetching a certain number of items so that we can ensure that a page is filled with a sufficient number of items?
I don't understand. This is the current default behaviour: every time we use useCollection
, the first page is prefetched.
Sorry, I think I wasn't very clear :)
Since the client cannot control the size of the page, the pages are possibly small (say 5 items).
So by setting prefetch
to 12
, the first three pages would be fetched at the beginning without additional calls to fetchNextPage
.
Indeed that seems useful. And if we don't want to prefetch any items, we can just set prefetch
to 0
.
I would expect prefetch
to be a boolean though, so maybe prefetchItems
or numItemsToPrefetch
would be better.
Add a new
fetchOnMount
option to the useCollection hook.If false (true by default), the collection will not be fetched on load but can be fetched later with the
refetch
For the
useInbox
anduseOutbox
hooks, it is false by default because most of the usages ofuseOutbox
is to post activities, and thus we don't need to fetch the outbox.TODO
refetch
worksuseOutbox
anduseInbox
still work, notably with awaitActivity and liveUpdates