Skip to content

//reactivestate-core/com.ensody.reactivestate/BaseSuspendMutableValueFlow

BaseSuspendMutableValueFlow

@ExperimentalReactiveStateApi

abstract class BaseSuspendMutableValueFlow<T> : ValueFlow<T> , SuspendMutableValueFlow<T>

Base class for StateFlows that can be mutated only via suspend functions - in contrast to assigning the value.

This is useful e.g. for values backed by some storage/backend system.

See also

SuspendMutableValueFlow for a simple lambda-based implementation.

Constructors

BaseSuspendMutableValueFlow [common]
constructor(value: T)

Properties

Name Summary
replayCache [common]
open override val replayCache: List<T>
value [common]
open override val value: T

Functions

Name Summary
addDelay [common]
fun <T> Flow<T>.addDelay(timeoutMillis: Long): Flow<T>
Adds a timeoutMillis delay to a Flow. If delay is zero or negative this is a no-op.
collect [common]
open suspend override fun collect(collector: FlowCollector<T>): Nothing
conflatedMap [common]
inline fun <T, R> Flow<T>.conflatedMap(timeoutMillis: Long = 0, crossinline transform: suspend (value: T) -> R): Flow<R>
Maps a conflated Flow with timeoutMillis delay between the first and last element.
conflatedTransform [common]
inline fun <T, R> Flow<T>.conflatedTransform(timeoutMillis: Long = 0, crossinline transform: suspend FlowCollector<R>.(value: T) -> Unit): Flow<R>
Transforms a conflated Flow with timeoutMillis delay between the first and last element.
conflatedWorker [common]
fun <T, R> Flow<T>.conflatedWorker(timeoutMillis: Long = 0, transform: FlowTransform<T, R>): Flow<R>
Executes each lambda in a Flow using conflatedMap.
debounceWorker [common]
fun <T, R> Flow<T>.debounceWorker(timeoutMillis: Long = 0, transform: FlowTransform<T, R>): Flow<R>
Executes each lambda in a Flow using debounce and map.
latestWorker [common]
fun <T, R> Flow<T>.latestWorker(timeoutMillis: Long = 0, transform: FlowTransform<T, R>): Flow<R>
Executes each lambda in a Flow using debounce and mapLatest.
onStateSubscription [common]
fun <T> StateFlow<T>.onStateSubscription(block: suspend FlowCollector<T>.() -> Unit): StateFlow<T>
Similar to StateFlow.onSubscription but returns a StateFlow.
replace [common]
open suspend override fun replace(block: T.() -> T)
Replaces the value with block’s return value.
set [common]
open suspend override fun set(value: T, force: Boolean)
Assigns a new value.
shareOnDemand [common]
fun <T> Flow<T>.shareOnDemand(replay: Int = 0, context: CoroutineContext = EmptyCoroutineContext): SharedFlow<T>
Turns this Flow into a SharedFlow without requiring a CoroutineScope (unlike shareIn).
stateOnDemand [common]
fun <T> Flow<T>.stateOnDemand(context: CoroutineContext = EmptyCoroutineContext, synchronous: Boolean = true, emitValueOnStart: Boolean = true, getter: (previous: Wrapped<T>?) -> T): StateFlow<T>
Turns this Flow into a StateFlow without requiring a CoroutineScope (unlike stateIn).
toMutable [common]
fun <T> StateFlow<T>.toMutable(setter: StateFlow<T>.(T) -> Unit): MutableStateFlow<T>
Converts this StateFlow to a MutableStateFlow that calls setter for doing the actual value update.
update [common]
open suspend override fun update(block: (value: T) -> Unit)
Mutates value in-place and notifies listeners. The current value is passed as an arg.
updateThis [common]
open suspend override fun updateThis(block: T.() -> Unit)
Mutates value in-place and notifies listeners. The current value is passed via this.
withRefresh [common]
@ExperimentalReactiveStateApi
fun <T> StateFlow<T>.withRefresh(block: suspend StateFlow<T>.(force: Boolean) -> Unit): RefreshableStateFlow<T>