feat(infinite-query): add setInfiniteQueryData support
This commit is contained in:
@@ -268,6 +268,23 @@ abstract class BaseQuery<T extends Object, Outside, Error>
|
||||
return isConnectedToInternet(await _connectivity.checkConnectivity());
|
||||
}
|
||||
|
||||
/// can be used to update the data manually. Can be useful when used
|
||||
/// together with mutations to perform optimistic updates or manual data
|
||||
/// updates
|
||||
/// For updating particular queries after a mutation using the
|
||||
/// `QueryBowl.refetchQueries` is more appropriate. But this one can be
|
||||
/// used when only 1 query needs get updated
|
||||
///
|
||||
/// Every time a new instance of data should be returned because of
|
||||
/// immutability
|
||||
void setQueryData(QueryUpdateFunction<T> updateFn) async {
|
||||
final newData = await updateFn(data);
|
||||
if (data == newData) return;
|
||||
data = newData;
|
||||
status = QueryStatus.success;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// invalidates the query
|
||||
///
|
||||
/// Forcefully makes the query stale & expired which results in a refetch
|
||||
|
||||
Reference in New Issue
Block a user