-
Notifications
You must be signed in to change notification settings - Fork 305
Feature Request : support for multiple get/fetch #369
Description
This is a feature I'd like to see added, though I could understand if it's too cumbersome or introduces the potential for added bugs.
My server has the ability to provide many raw items in a single call; but the fetcher operates one at a time, so I have to use a different endpoint to get items from the server for one at a time. Not a huge issue but I feel like it's better (and faster) to have one request over multiple requests. I did a quick test and 25 items loaded in 41% of the time via a singular call vs 25 individual calls.
There could be an optional method on fetchers that would be automatically triggered (similarly to the debouncer) For example, if many get calls are called consecutively using different keys, the fetcher will call the multiple fetcher method instead of the singular method for each one.
Or it could have explicit syntax such as getMultiple
or fetchMultiple
etc.
I understand this could add some complexities and corner cases,
- Some items in a multiple fetch may already be cached, meaning there has to be some resolution between those that are cached and those that are being fetched from the network - AND the order must be retained
- The server may return some invalid items (i.e. null)
- The server may return items in a different order than they were requested. Mine doesn't but that may not be the case for everyone, and a potential source for bugs
- What happens when the amount of items returned does not match the amount requested? For example, we request 15 and we get 14 (which one is missing?). Or even worse we get back 16 (which one is extraneous??)
Some of these issues could be resolved by adding another method that allows you to explicitly map a raw item to its key. However that's not something that's in the library at the moment (I assume for good reason)
This may be related to #366