Skip to content

Commit

Permalink
return stale data when fetching. User can decide to keep or toss.
Browse files Browse the repository at this point in the history
  • Loading branch information
tantaman committed Dec 11, 2023
1 parent 3c640fa commit ea50e5d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/react/src/queryHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ class AsyncResultStateMachine<T, M = readonly T[]> {
this.pendingFetchPromise = null;
this.queriedTables = null;
this.error = undefined;
if (this.data != null) {
this.fetchingState = {
...this.data,
loading: true,
} as any;
}
this.data = null;
this.pullData(true);
};
Expand Down Expand Up @@ -252,6 +258,12 @@ class AsyncResultStateMachine<T, M = readonly T[]> {

this.pendingFetchPromise = null;
this.error = undefined;
if (this.data != null) {
this.fetchingState = {
...this.data,
loading: true,
} as any;
}
this.data = null;
this.pullData(true);
};
Expand Down

0 comments on commit ea50e5d

Please sign in to comment.