Handling more granular variants of fetch states with AsyncData or similar #40
-
Hello! I have a question rather than an issue. Hopefully not in the wrong forum, if so do tell and I will correct. Library looks awesome. I've just recently been experimenting with something similar to My case is that I want to 'patch' the query result from a basic My question is if there are any examples of how to model this with this library, or if someone could point me in the right direction. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
hi! for that case I'd recommend to use two type ReloadableAsyncData<T> = {
data: AsyncData<T>;
nextData: AsyncData<T>;
} In // initial state
{data: AsyncData.NotAsked(), nextData: AsyncData.NotAsked()}
// first load
{data: AsyncData.Loading(), nextData: AsyncData.NotAsked()}
// first data received
{data: AsyncData.Done(v1), nextData: AsyncData.NotAsked()}
// reload started
{data: AsyncData.Done(v1), nextData: AsyncData.Loading()}
// reload done
{data: AsyncData.Done(v2), nextData: AsyncData.NotAsked()} this modeling also works for paginated queries, where you can aggregate in |
Beta Was this translation helpful? Give feedback.
hi!
for that case I'd recommend to use two
AsyncData
instances:In
data
you can keep the last committed update, and innextData
the current update:this modeling also works for paginated queries, where you can aggregate in
data
and…