ZenInfiniteQuery<T> constructor

ZenInfiniteQuery<T>({
  1. required Object queryKey,
  2. required Future<T> infiniteFetcher(
    1. dynamic pageParam,
    2. ZenCancelToken cancelToken
    ),
  3. required dynamic getNextPageParam(
    1. T lastPage,
    2. List<T> allPages
    ),
  4. dynamic getPreviousPageParam(
    1. T firstPage,
    2. List<T> allPages
    )?,
  5. dynamic initialPageParam,
  6. ZenQueryConfig? config,
  7. List<T>? initialData,
  8. ZenScope? scope,
  9. bool autoDispose = true,
})

Implementation

ZenInfiniteQuery({
  required super.queryKey,
  required this.infiniteFetcher,
  required this.getNextPageParam,
  this.getPreviousPageParam,
  this.initialPageParam,
  super.config,
  super.initialData,
  super.scope,
  super.autoDispose,
})  : _nextPageParam = initialPageParam,
      _previousPageParam =
          initialPageParam, // Initially same, logic corrects it
      super(
        // The main fetcher (for initial load/refetch)
        fetcher: (token) async {
          // Pass the token to the infinite fetcher
          final firstPage = await infiniteFetcher(initialPageParam, token);
          return [firstPage];
        },
      );