- Lit Reference
- Classes / CancelledError
- Classes / InfiniteQueryObserver
- Classes / Mutation
- Classes / MutationCache
- Classes / MutationObserver
- Classes / QueriesObserver
- Classes / Query
- Classes / QueryCache
- Classes / QueryClient
- Classes / QueryClientProvider
- Classes / QueryObserver
- Functions / createInfiniteQueryController
- Functions / createMutationController
- Functions / createQueriesController
- Functions / createQueryController
- Functions / defaultShouldDehydrateMutation
- Functions / defaultShouldDehydrateQuery
- Functions / dehydrate
- Functions / dehydrateQuery
- Functions / experimental_streamedQuery
- Functions / hashKey
- Functions / hydrate
- Functions / infiniteQueryOptions
- Functions / isCancelledError
- Functions / keepPreviousData
- Functions / matchMutation
- Functions / matchQuery
- Functions / mutationOptions
- Functions / noop
- Functions / partialMatchKey
- Functions / queryOptions
- Functions / replaceEqualDeep
- Functions / shouldThrowError
- Functions / useIsFetching
- Functions / useIsMutating
- Functions / useMutationState
- Functions / useQueryClient
- Context / queryClientContext
- Context / getDefaultQueryClient
- Context / registerDefaultQueryClient
- Context / unregisterDefaultQueryClient
- Context / resolveQueryClient
- Interfaces / CancelOptions
- Interfaces / DefaultOptions
- Interfaces / DehydrateOptions
- Interfaces / DehydratedState
- Interfaces / EnsureQueryDataOptions
- Interfaces / FetchNextPageOptions
- Interfaces / FetchPreviousPageOptions
- Interfaces / FetchQueryOptions
- Interfaces / FocusManager
- Interfaces / HydrateOptions
- Interfaces / InfiniteData
- Interfaces / InfiniteQueryObserverBaseResult
- Interfaces / InfiniteQueryObserverLoadingErrorResult
- Interfaces / InfiniteQueryObserverLoadingResult
- Interfaces / InfiniteQueryObserverOptions
- Interfaces / InfiniteQueryObserverPendingResult
- Interfaces / InfiniteQueryObserverPlaceholderResult
- Interfaces / InfiniteQueryObserverRefetchErrorResult
- Interfaces / InfiniteQueryObserverSuccessResult
- Interfaces / InfiniteQueryPageParamsOptions
- Interfaces / InitialPageParam
- Interfaces / InvalidateOptions
- Interfaces / InvalidateQueryFilters
- Interfaces / MutateOptions
- Interfaces / MutationCacheConfig
- Interfaces / MutationFilters
- Interfaces / MutationObserverBaseResult
- Interfaces / MutationObserverErrorResult
- Interfaces / MutationObserverIdleResult
- Interfaces / MutationObserverLoadingResult
- Interfaces / MutationObserverOptions
- Interfaces / MutationObserverSuccessResult
- Interfaces / MutationOptions
- Interfaces / MutationState
- Interfaces / NotifyEvent
- Interfaces / OnlineManager
- Interfaces / QueriesObserverOptions
- Interfaces / QueryCacheConfig
- Interfaces / QueryClientConfig
- Interfaces / QueryExecuteOptions
- Interfaces / QueryFilters
- Interfaces / QueryObserverBaseResult
- Interfaces / QueryObserverLoadingErrorResult
- Interfaces / QueryObserverLoadingResult
- Interfaces / QueryObserverOptions
- Interfaces / QueryObserverPendingResult
- Interfaces / QueryObserverPlaceholderResult
- Interfaces / QueryObserverRefetchErrorResult
- Interfaces / QueryObserverSuccessResult
- Interfaces / QueryOptions
- Interfaces / QueryState
- Interfaces / RefetchOptions
- Interfaces / RefetchQueryFilters
- Interfaces / Register
- Interfaces / ResetOptions
- Interfaces / ResultOptions
- Interfaces / SetDataOptions
- Interfaces / TimeoutManager
- Types / Accessor
- Types / AnyDataTag
- Types / CreateInfiniteQueryOptions
- Types / CreateMutationOptions
- Types / CreateQueriesControllerOptions
- Types / CreateQueriesInput
- Types / CreateQueryOptions
- Types / DataTag
- Types / DefaultError
- Types / DefaultedInfiniteQueryObserverOptions
- Types / DefaultedQueryObserverOptions
- Types / DefinedInfiniteQueryObserverResult
- Types / DefinedInitialDataOptions
- Types / DefinedQueryObserverResult
- Types / DistributiveOmit
- Types / EnsureInfiniteQueryDataOptions
- Types / FetchInfiniteQueryOptions
- Types / FetchStatus
- Types / GetNextPageParamFunction
- Types / GetPreviousPageParamFunction
- Types / InferDataFromTag
- Types / InferErrorFromTag
- Types / InfiniteQueryControllerOptions
- Types / InfiniteQueryExecuteOptions
- Types / InfiniteQueryObserverResult
- Types / InfiniteQueryResultAccessor
- Types / InitialDataFunction
- Types / IsFetchingAccessor
- Types / IsMutatingAccessor
- Types / ManagedTimerId
- Types / MutateFunction
- Types / MutateFunctionRest
- Types / MutationCacheNotifyEvent
- Types / MutationControllerOptions
- Types / MutationControllerResult
- Types / MutationFunction
- Types / MutationFunctionContext
- Types / MutationKey
- Types / MutationMeta
- Types / MutationObserverResult
- Types / MutationResultAccessor
- Types / MutationScope
- Types / MutationStateAccessor
- Types / MutationStateOptions
- Types / MutationStatus
- Types / NetworkMode
- Types / NonUndefinedGuard
- Types / NotifyEventType
- Types / NotifyOnChangeProps
- Types / OmitKeyof
- Types / Override
- Types / PlaceholderDataFunction
- Types / QueriesControllerOptions
- Types / QueriesPlaceholderDataFunction
- Types / QueriesResultAccessor
- Types / QueryBooleanOption
- Types / QueryCacheNotifyEvent
- Types / QueryControllerOptions
- Types / QueryControllerResult
- Types / QueryFunction
- Types / QueryFunctionContext
- Types / QueryKey
- Types / QueryKeyHashFunction
- Types / QueryKeyWithDataTag
- Types / QueryMeta
- Types / QueryObserverResult
- Types / QueryPersister
- Types / QueryResultAccessor
- Types / QueryStatus
- Types / SkipToken
- Types / StaleTime
- Types / StaleTimeFunction
- Types / ThrowOnError
- Types / TimeoutCallback
- Types / TimeoutProvider
- Types / UndefinedInitialDataOptions
- Types / UnsetMarker
- Types / UnusedSkipTokenOptions
- Types / Updater
- Types / ValueAccessor
- Types / WithRequired
- Types / dataTagErrorSymbol
- Types / dataTagSymbol
- Variables / dataTagErrorSymbol
- Variables / dataTagSymbol
- Variables / defaultScheduler
- Variables / environmentManager
- Variables / focusManager
- Variables / isServer
- Variables / notifyManager
- Variables / onlineManager
- Variables / skipToken
- Variables / timeoutManager
- Variables / unsetMarker
createInfiniteQueryController
function createInfiniteQueryController<TQueryFnData = unknown, TError = Error, TData = InfiniteData<TQueryFnData, unknown>, TQueryKey extends readonly unknown[] = readonly unknown[], TPageParam = unknown>(
host: ReactiveControllerHost,
options: Accessor<CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>>,
queryClient?: QueryClient
): InfiniteQueryResultAccessor<TData, TError>;Defined in: packages/lit-query/src/createInfiniteQueryController.ts:401
Creates a Lit reactive controller that subscribes the host to an infinite query.
The returned accessor is callable and also exposes current, refetch, fetchNextPage, fetchPreviousPage, and destroy. When options is a function, it is re-read during host updates so query keys and options can follow reactive host state.
If queryClient is omitted, the controller resolves the client from the nearest connected QueryClientProvider.
Type Parameters#
TQueryFnData#
TQueryFnData = unknown
TError#
TError = Error
TData#
TData = InfiniteData<TQueryFnData, unknown>
TQueryKey#
TQueryKey extends readonly unknown[] = readonly unknown[]
TPageParam#
TPageParam = unknown
Parameters#
host#
ReactiveControllerHost
The Lit reactive controller host that owns the infinite query subscription.
options#
Accessor<CreateInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>>
Infinite query observer options, or a getter that returns options.
options properties#
Built from InfiniteQueryObserverOptions. See the type above for what it changes.
queryClient?#
Optional explicit query client. Provide this for controllers that should not resolve a client from Lit context.
Returns#
InfiniteQueryResultAccessor<TData, TError>
An accessor for the latest infinite query result with page helper methods.
Example#
import { LitElement, html } from 'lit'
import { createInfiniteQueryController } from '@tanstack/lit-query'
class ProjectsView extends LitElement {
private readonly projects = createInfiniteQueryController(this, {
queryKey: ['projects'],
queryFn: ({ pageParam }) => fetchProjects(pageParam),
initialPageParam: 0,
getNextPageParam: (lastPage) => lastPage.nextCursor,
})
render() {
const query = this.projects()
return html`
<button ?disabled=${!query.hasNextPage} @click=${() => this.projects.fetchNextPage()}>
Load more
</button>
`
}
}