createInfiniteQueryFactory
createInfiniteQueryFactory<
Service,Transform,Method,TPageParam,Selected>(reactor,config):InfiniteQueryFactoryFn<Service,Method,Transform,TPageParam,Selected>
Defined in: react/src/createInfiniteQuery.ts:529
Create an infinite query factory that accepts getArgs at call time. Useful when pagination logic varies by context.
Type Parameters
Section titled “Type Parameters”Service
Section titled “Service”Service
The actor interface type
Transform
Section titled “Transform”Transform extends keyof TransformArgsRegistry<unknown>
The transformation key (identity, display, etc.)
Method
Section titled “Method”Method extends string = FunctionName<Service>
The method name on the actor
TPageParam
Section titled “TPageParam”TPageParam = unknown
The page parameter type
Selected
Section titled “Selected”Selected = InfiniteData<ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>, TPageParam>
The type returned after select transformation
Parameters
Section titled “Parameters”reactor
Section titled “reactor”Reactor<Service, Transform>
The Reactor instance
config
Section titled “config”InfiniteQueryFactoryConfig<NoInfer<Service>, Method, Transform, TPageParam, Selected>
Infinite query configuration (without getArgs)
Returns
Section titled “Returns”InfiniteQueryFactoryFn<Service, Method, Transform, TPageParam, Selected>
A function that accepts getArgs and returns an ActorInfiniteQueryResult
Example
Section titled “Example”const getPostsQuery = createActorInfiniteQueryFactory(reactor, { functionName: "get_posts", initialPageParam: 0, getKeyArgs: (args) => { const [{ userId }] = args return [{ userId }] }, getNextPageParam: (lastPage) => lastPage.nextCursor,})
// Create query with specific args builderconst userPostsQuery = getPostsQuery((cursor) => [{ userId, cursor, limit: 10 }])const { data, fetchNextPage } = userPostsQuery.useInfiniteQuery()