KRTirtho / fl-query

Asynchronous data fetching & data invalidation libraries for Flutter
https://fl-query.krtirtho.dev/
Apache License 2.0
60 stars 11 forks source link

refetchQueries not working as intented #23

Closed PetrKubes97 closed 8 months ago

PetrKubes97 commented 1 year ago

The current implementation of refetchQueries refetches all queries NOT specified in the list. Should be reverse. I think.

  /// refetches all the queries matching the passed List of queryKeys
  ///
  /// If an empty list of [queryKeys] is passed then all of the queries
  /// will be refetched
  Future<void> refetchQueries(List<String> queryKeys) async {
    for (final query in cache.queries) {
      if (queryKeys.isNotEmpty && queryKeys.contains(query.queryKey)) continue;
      await query.refetch();
    }
  }
KRTirtho commented 1 year ago

Oh, this is the old implementation of fl_query. Currently, in v1 this was changed, instead of using refetch we have separate refresh and refreshAll which resolves this confusing behavior But fl_query@v1 is in alpha currently and the jobs API (QueryJob, MutationJob, InfiniteQuery) is still not enabled, so major refactorings will be needed

affansk commented 1 year ago

@KRTirtho this package will be life saving, will get rid of lot of boilerplate which comes with other Packages. When are you planning to release stable version ?

KRTirtho commented 1 year ago

Hey, v1.0.0 was released last week :D

KRTirtho commented 1 year ago

@PetrKubes97 please check now. Jobs API has been brought back and now with few refactors, all should just work better than before

PetrKubes97 commented 12 months ago

@KRTirtho I've migrated the code and seems to work great. 🥳 The only issue I've found was 1:1 replacement of mutateAsync with useMutateJob and scheduleToQueue: true, but wasn't looking too deep into it, maybe a feature, not a bug.