ReplicaClient

interface ReplicaClient

Creates and manages replicas.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun <K : Any, T : Any> createKeyedReplica(    name: String,     childName: (K) -> String,     settings: KeyedReplicaSettings<K, T> = KeyedReplicaSettings(),     childSettings: (K) -> ReplicaSettings,     tags: Set<ReplicaTag> = emptySet(),     childTags: (K) -> Set<ReplicaTag> = { emptySet() },     behaviours: List<KeyedReplicaBehaviour<K, T>> = emptyList(),     childBehaviours: (K) -> List<ReplicaBehaviour<T>> = { emptyList() },     storage: KeyedStorage<K, T>? = null,     fetcher: KeyedFetcher<K, T>): KeyedPhysicalReplica<K, T>

Creates a KeyedPhysicalReplica. Note: once created a keyed replica will exist as long as a client exists.

Link copied to clipboard
abstract fun <T : Any> createReplica(    name: String,     settings: ReplicaSettings,     tags: Set<ReplicaTag> = emptySet(),     behaviours: List<ReplicaBehaviour<T>> = emptyList(),     storage: Storage<T>? = null,     fetcher: Fetcher<T>): PhysicalReplica<T>

Creates a PhysicalReplica. Note: once created a replica will exist as long as a client exists.

Link copied to clipboard
abstract suspend fun onEachKeyedReplica(action: suspend KeyedPhysicalReplica<*, *>.() -> Unit)

Executes an action on each KeyedPhysicalReplica.

Link copied to clipboard
abstract suspend fun onEachReplica(includeChildrenOfKeyedReplicas: Boolean = true, action: suspend PhysicalReplica<*>.() -> Unit)

Executes an action on each PhysicalReplica.

Properties

Link copied to clipboard
abstract val coroutineScope: CoroutineScope

A coroutine scope that represents life time of a client.

Link copied to clipboard
abstract val eventFlow: Flow<ReplicaClientEvent>

Notifies that some ReplicaClientEvent has occurred.

Link copied to clipboard
abstract val networkConnectivityProvider: NetworkConnectivityProvider?

Returns NetworkConnectivityProvider that was passed to create a client.

Extensions

Link copied to clipboard
suspend fun ReplicaClient.cancelAll()

Cancels network requests in all replicas.

Link copied to clipboard
suspend fun ReplicaClient.cancelByTags(predicate: (Set<ReplicaTag>) -> Boolean)

Cancels network requests in replicas with the matching tags.

Link copied to clipboard
suspend fun ReplicaClient.clearAll()

Cancels network requests and clears data in all replicas.

Link copied to clipboard
suspend fun ReplicaClient.clearByTags(predicate: (Set<ReplicaTag>) -> Boolean)

Cancels network requests and clears data in replicas with the matching tags.

Link copied to clipboard
suspend fun ReplicaClient.invalidateAll(mode: InvalidationMode = InvalidationMode.RefreshIfHasObservers)

Makes all replicas stale.

Link copied to clipboard
suspend fun ReplicaClient.invalidateByTags(mode: InvalidationMode = InvalidationMode.RefreshIfHasObservers, predicate: (Set<ReplicaTag>) -> Boolean)

Makes replicas with the matching tags stale.