QueryFactoryWithInput

class QueryFactoryWithInput<TInput : CacheableInput.QueryInput, TData, TError : Throwable>(cache: OnHandCache, dispatcher: CoroutineDispatcher = Dispatchers.Default, ttl: Duration? = null, query: suspend (input: TInput) -> TData)

Factory for creating CacheableQueryWithInput instances.

The query lambda runs on Dispatchers.Default. If your query performs IO (network, disk), use withContext(Dispatchers.IO) inside your lambda. Do not use launch or async inside the lambda without awaiting — the fetch must complete sequentially so that state transitions (LOADING → SUCCESS/ERROR) are correct.

Constructors

Link copied to clipboard
constructor(cache: OnHandCache, dispatcher: CoroutineDispatcher = Dispatchers.Default, ttl: Duration? = null, query: suspend (input: TInput) -> TData)

Functions

Link copied to clipboard
fun create(startingCacheKey: TInput? = null, coroutineScope: CoroutineScope, initialFetchState: FetchState = FetchState.IDLE): CacheableQueryWithInput<TInput, TData, TError>
Link copied to clipboard
operator fun invoke(startingCacheKey: TInput? = null, coroutineScope: CoroutineScope, initialFetchState: FetchState = FetchState.IDLE): CacheableQueryWithInput<TInput, TData, TError>
Link copied to clipboard
fun optimisticUpdater(input: TInput, updater: (currentValue: TData?) -> TData): Map<TInput, TData?>
Link copied to clipboard
suspend fun refetch(input: TInput)