Package me.aartikov.replica.common

Types

Link copied to clipboard
data class CombinedLoadingError(val exceptions: List<Exception>)

Represent several errors (one or more) occurred during a network request.

Link copied to clipboard
enum InvalidationMode : Enum<InvalidationMode>

Specifies how a replica behaves after invalidation.

Link copied to clipboard
data class LoadingError(val exception: Exception)

Represent an error occurred during a network request.

Link copied to clipboard
data class ObservingState(    val observerIds: Set<Long> = emptySet(),     val activeObserverIds: Set<Long> = emptySet(),     val observingTime: ObservingTime = ObservingTime.Never)

Has information about observers of a replica.

Link copied to clipboard
enum ObservingStatus : Enum<ObservingStatus>
Link copied to clipboard
interface ObservingTime : Comparable<ObservingTime>

Represent information when a replica was observed in last time.

Link copied to clipboard
fun interface OptimisticUpdate<T : Any>

Action executed for optimistic update

Link copied to clipboard
value class ReplicaId(val value: Long)

Unique identifier for a replica.

Link copied to clipboard
interface ReplicaTag

Can be used to perform bulk operations on a subset of replicas. See: cancelByTags, clearByTags, invalidateByTags.

Functions

Link copied to clipboard
fun <T : Any> List<OptimisticUpdate<T>>.applyAll(data: T): T
Link copied to clipboard
inline suspend fun <R> performOptimisticUpdate(    begin: () -> Unit,     commit: () -> Unit,     crossinline rollback: suspend () -> Unit,     noinline onSuccess: suspend () -> Unit? = null,     noinline onError: suspend (Exception) -> Unit? = null,     noinline onCanceled: suspend () -> Unit? = null,     noinline onFinished: suspend () -> Unit? = null,     block: () -> R): R

Executes begin and then block. If an operation succeed than commit is executed, otherwise rollback is executed. onSuccess, onError, onCanceled, onFinished are optional callbacks for additional actions.