FetchPolicy

sealed interface FetchPolicy

Whether a screen reads from cache, the network, or both — the read strategy a caller hands to its store stream. Kept as a sealed interface so new variants can be added without breaking the FetchPolicy.NetworkWithCache access pattern.

ScenarioPolicy
Normal screen — show cache instantly, refresh in backgroundNetworkWithCache (default)
Must-be-fresh (payment status, post-transaction balance)NetworkOnly
Explicit offline / "load from cache"CacheOnly
Ambient surface that re-fetches on a cadence (tickers, FX)Periodic

Inheritors

Types

Link copied to clipboard
data object CacheOnly : FetchPolicy

Read cache only; never hit the network. Empty cache emits ScreenState.Empty.

Link copied to clipboard
data object NetworkOnly : FetchPolicy

Always hit the network; on failure emit ScreenState.NoNetwork/ScreenState.Error, not stale data.

Link copied to clipboard

Emit cache immediately (if any), then fetch and emit the refreshed value. The default.

Link copied to clipboard
data class Periodic(val intervalMs: Long) : FetchPolicy

NetworkWithCache read semantics plus a periodic background refresh every intervalMs. intervalMs must be positive; sub-second cadences are wasteful on mobile.