Skip to content

Commit

Permalink
fix: add reset of _currentFuture with whenComplete handler (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
iOSonntag authored May 22, 2024
1 parent bcb4c05 commit bf75ef0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/cached_query/lib/src/query_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ abstract class QueryBase<T, State extends QueryState<dynamic>> {

final CachedQuery _globalCache = CachedQuery.instance;
Timer? _deleteQueryTimer;
Future<void>? _currentFuture;
Future<void>? _f;
Future<void>? get _currentFuture => _f;

set _currentFuture(Future<void>? future) {
_f = future?.whenComplete(() {
_currentFuture = null;
});
}

// Initialise the query as stale so the first fetch is guaranteed to happen
bool _staleOverride = true;
Expand Down

0 comments on commit bf75ef0

Please sign in to comment.