
commonMain.me.aartikov.replica.paged.PagedReplicaSettings.kt Maven / Gradle / Ivy
package me.aartikov.replica.paged
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
/**
* Configures behaviour of a paged replica.
* @property staleTime specifies how quickly fetched data will became stale (null means never).
* @property clearTime specifies how quickly data will be cleared when there is no observers (null means never).
* @property clearErrorTime specifies how quickly error will be cleared when there is no observers (null means never).
* @property cancelTime specifies how quickly request will be canceled when there is no observers (null means never).
* @property revalidateOnActiveObserverAdded specifies if stale data will be refreshed when an active observer is added.
* @property revalidateOnNetworkConnection specifies if stale data will be refreshed when a network connection is established and a replica has active observer. Note: [NetworkConnectivityProvider] has to be added to [ReplicaClient].
*/
data class PagedReplicaSettings(
val staleTime: Duration?,
val clearTime: Duration? = null,
val clearErrorTime: Duration? = 250.milliseconds,
val cancelTime: Duration? = 250.milliseconds,
val revalidateOnActiveObserverAdded: Boolean = true,
val revalidateOnNetworkConnection: Boolean = true
) {
companion object {
/**
* Settings for a paged replica with none automatic behaviour.
*/
val WithoutBehaviour = PagedReplicaSettings(
staleTime = null,
clearTime = null,
clearErrorTime = null,
cancelTime = null,
revalidateOnActiveObserverAdded = false,
revalidateOnNetworkConnection = false
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy