Replies: 2 comments
-
This seems to be what #178 does |
Beta Was this translation helpful? Give feedback.
-
Ooo, you're right! I think I overlooked it, as I was imagining I think if I combine #178 with 'Optimistic updates', I think I can pull off everything here. Specifically:
I may need to see if there is a way to ensure that the That said... I think this is going to be much more elegant code and better performance than my older system. By the way, I really enjoy the way that optimistic updates were implemented. It will grant me much more flexibility than I had in the past. (Perhaps similar was possible with Tanstack, but I didn't find a lot of documentation on the API for these purposes). |
Beta Was this translation helpful? Give feedback.
-
The Short Version
It'd be nice to have a way for being able to query multiple feeds(of a variable size), and to aggregate their data together. This is something that would probably need discussion, as I figure there are multiple strategies for it.
To me, the main reason I ask, is to see about a way to support multiple queries with caching, pagination, deduplication and status information
Long Version
I'm trying to figure out how to combine multiple queries under one state machine. I'm pretty sure that this is possible, just don't know the best way to pull this off with the API. (I figure some application of
useQueryCache()
)I have a complex scenario where I am pulling a user-defined amount of feeds (say size M), and each feed is paginated (default 20 elements). This feed system is unfortunately the key feature of my application, and thus not something I can really simplify.
Since my UI only needs to render the latest created 20 elements, I sort the aggregation of each feed, and slice 20 from that dataset. Now comes the fun part, how to handle user pagination, reactivity and caching?
My old system (based on tanstack):
MultiPaginator
, that tracks all the configured feeds, as well as defines an aggregate page position.Promise.all(feeds)
operation, and I pass the returned data into a new instance ofMultiPaginator
MultiPaginator
will do some checks to see the next page has reached the end of each feed, and if so, it'll fetch the next 20 elements for those feeds. (Similar process for previous page). Each fetch operation runs through the cache and thus populates for future queries.MultiPaginator
will do some logic to determine variables such as cursor position, length, and totalLengthnextPage()
andprevPage()
methods were wrapped with auseAsyncData()
composable from vueuse.Where the challenges are for migrating to this library (by step):
QueryClient.fetchQuery
)MultiPaginator
just fine, as a lot of the aggregation functions are the same.nextPage()
orprevPage()
function on myMultiPaginator
class, the class will retrieve data, but I don't know how to inject it into the cache.I'm starting to wonder, perhaps there is a better way. And to which, I'd love to help contribute to this library to pave the way for one. (I'll likely still build something for myself in the meantime).
I did see #102, my main problem, is that my queries are of a variable size.
I'd especially like if I had a single UseQueryReturn, instead of the 3 I'll have with my current development path.
Beta Was this translation helpful? Give feedback.
All reactions