feat: implement refetchOnApplicationResume and refetchOnWindowFocus

This commit is contained in:
Kingkor Roy Tirtho
2022-10-08 12:44:59 +06:00
parent f0d3bd36a7
commit cd567efb95
10 changed files with 144 additions and 6 deletions
+16
View File
@@ -41,6 +41,9 @@ abstract class BaseQuery<T extends Object, Outside, Error>
Timer? _refetchIntervalTimer;
bool? refetchOnApplicationResume;
bool? refetchOnWindowFocus;
Connectivity _connectivity;
T? _previousData;
@@ -56,6 +59,8 @@ abstract class BaseQuery<T extends Object, Outside, Error>
this.refetchOnMount,
this.refetchOnReconnect,
this.refetchInterval,
this.refetchOnApplicationResume,
this.refetchOnWindowFocus,
this.enabled = true,
T? previousData,
Connectivity? connectivity,
@@ -245,6 +250,8 @@ abstract class BaseQuery<T extends Object, Outside, Error>
Duration? cacheTime,
bool? refetchOnMount,
bool? refetchOnReconnect,
bool? refetchOnApplicationResume,
bool? refetchOnWindowFocus,
}) {
bool updated = false;
if (this.refetchInterval == null &&
@@ -272,6 +279,15 @@ abstract class BaseQuery<T extends Object, Outside, Error>
this.refetchOnReconnect = refetchOnReconnect;
updated = true;
}
if (this.refetchOnApplicationResume == null &&
refetchOnApplicationResume != null) {
this.refetchOnApplicationResume = refetchOnApplicationResume;
updated = true;
}
if (this.refetchOnWindowFocus == null && refetchOnWindowFocus != null) {
this.refetchOnWindowFocus = refetchOnWindowFocus;
updated = true;
}
if (updated) notifyListeners();
}