SwrClient

An all-in-one SwrClient integrating MutationClient and QueryClient for library users.

Swr stands for "stall-while-revalidate".

Inheritors

Properties

Link copied to clipboard
abstract val errorRelay: Flow<ErrorRecord>

Provides a unified feedback mechanism for all Query/Mutation errors that occur within the client.

Link copied to clipboard

Note: This property is exposed for limited use cases where you may need to call MutationKey.mutate manually. It can be useful as an escape hatch or for synchronous invocations within the data layer.

Link copied to clipboard

Note: This property is exposed for limited use cases where you may need to call QueryKey.fetch and InfiniteQueryKey.fetch manually. It can be useful as an escape hatch or for synchronous invocations within the data layer.

Functions

Link copied to clipboard
abstract fun effect(block: Effect): Job

Executes side effects for queries.

Link copied to clipboard
abstract fun gc(level: MemoryPressureLevel = MemoryPressureLevel.Low)

Releases data in memory based on the specified level.

Link copied to clipboard
abstract fun <T, S> getInfiniteQuery(key: InfiniteQueryKey<T, S>, marker: Marker = Marker.None): InfiniteQueryRef<T, S>

Gets the InfiniteQueryRef by the specified InfiniteQueryKey.

Link copied to clipboard
abstract fun <T, S> getMutation(key: MutationKey<T, S>, marker: Marker = Marker.None): MutationRef<T, S>

Gets the MutationRef by the specified MutationKey.

Link copied to clipboard
abstract fun <T> getQuery(key: QueryKey<T>, marker: Marker = Marker.None): QueryRef<T>

Gets the QueryRef by the specified QueryKey.

Link copied to clipboard
abstract fun onMount(id: String)

Executes initialization procedures based on events.

Link copied to clipboard
abstract fun onUnmount(id: String)

Executes cleanup procedures based on events.

Link copied to clipboard
abstract fun perform(sideEffects: QueryEffect): Job

Executes side effects for queries.

Link copied to clipboard
abstract fun <T, S> prefetchInfiniteQuery(key: InfiniteQueryKey<T, S>, marker: Marker = Marker.None): Job

Prefetches the infinite query by the specified InfiniteQueryKey.

Link copied to clipboard
abstract fun <T> prefetchQuery(key: QueryKey<T>, marker: Marker = Marker.None): Job

Prefetches the query by the specified QueryKey.

Link copied to clipboard
abstract fun purgeAll()

Removes all queries and mutations from the in-memory stored data.