All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.me.aartikov.replica.single.ReplicaEvent.kt Maven / Gradle / Ivy

package me.aartikov.replica.single

/**
 * Notifies that something happened in [PhysicalReplica].
 */
sealed interface ReplicaEvent {

    sealed interface LoadingEvent : ReplicaEvent {
        object LoadingStarted : LoadingEvent

        data class DataFromStorageLoaded(val data: T) : LoadingEvent

        sealed interface LoadingFinished : LoadingEvent {
            data class Success(val data: T) : LoadingFinished
            object Canceled : LoadingFinished
            data class Error(val exception: Exception) : LoadingFinished
        }
    }

    sealed interface FreshnessEvent : ReplicaEvent {
        object Freshened : FreshnessEvent
        object BecameStale : FreshnessEvent
    }

    object ClearedEvent : ReplicaEvent

    data class ObserverCountChangedEvent(
        val count: Int,
        val activeCount: Int,
        val previousCount: Int,
        val previousActiveCount: Int
    ) : ReplicaEvent
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy