FlowObservable

class FlowObservable<T>(val coroutineScope: CoroutineScope, context: CoroutineContext = coroutineScope.coroutineContext, val flow: Flow<T>, observation: ObservationUninitialized<T> = ObservationUninitialized()) : BaseUninitializedObservable<T>

A BaseUninitializedObservable that observes the state of a Flow

Parameters

T

the type of value to expect.

coroutineScope

The CoroutineScope on which to observe the Flow

context

The CoroutineContext in which to observe the Flow

flow

The Flow to observe

observation

The ObservationUninitialized to observe the Flow

Constructors

Link copied to clipboard
constructor(coroutineScope: CoroutineScope, context: CoroutineContext = coroutineScope.coroutineContext, flow: Flow<T>, observation: ObservationUninitialized<T> = ObservationUninitialized())

Properties

Link copied to clipboard
val coroutineScope: CoroutineScope
Link copied to clipboard
open override val currentOrNull: T?

The current value T or null being observed

Link copied to clipboard
val flow: Flow<T>
Link copied to clipboard

The initial ObservableOptional value of T.

Link copied to clipboard
expect open override val stateFlow: StateFlow<T?>

StateFlow that expresses the content from the observable.

Link copied to clipboard
expect open override val valueDelegate: ReadOnlyProperty<Any?, T?>

Functions

Link copied to clipboard
open operator override fun getValue(thisRef: Any?, property: KProperty<*>): ObservableOptional<T>
Link copied to clipboard
open override fun observe(onNext: (T?) -> Unit): Disposable

Creates an observation that calls onNext each time a new value is observed until the resulting Disposable is disposed

Link copied to clipboard
fun <T> WithState<T?>.observeNotNullOnLifecycle(lifecycleOwner: LifecycleOwner, filter: suspend (T) -> Boolean = { true }, onNext: (T) -> Unit): Job

Observes WithState of a nullable value on the lifecycle of a LifecycleOwner

Link copied to clipboard
fun <T> WithState<T>.observeOnLifecycle(lifecycleOwner: LifecycleOwner, filter: suspend (T) -> Boolean = { true }, onNext: (T) -> Unit): Job

Observes WithState on the lifecycle of a LifecycleOwner

fun <T, R> WithState<T>.observeOnLifecycle(lifecycleOwner: LifecycleOwner, filter: suspend (T) -> Boolean = { true }, transform: suspend (T) -> R, onNext: (R) -> Unit): Job

Observes WithState on the lifecycle of a LifecycleOwner by transforming the observed value.