feat(infinite-query): add refetchPages, refetchOnStale, refetchOnMount support

This commit is contained in:
Kingkor Roy Tirtho
2022-09-14 12:49:30 +06:00
parent 61958c7d94
commit 95b1837620
20 changed files with 257 additions and 104 deletions
+12
View File
@@ -85,6 +85,18 @@ class Query<T extends Object, Outside> extends BaseQuery<T, Outside, dynamic> {
queryKey: options.queryKey,
);
@override
Timer createRefetchTimer() {
return Timer.periodic(
refetchInterval!,
(_) async {
// only refetch if its connected to the internet or refetch will
// always result in error while there's no internet
if (isStale && await isInternetConnected()) await refetch();
},
);
}
/// can be used to update the data manually. Can be useful when used
/// together with mutations to perform optimistic updates or manual data
/// updates