FlowToStateFlow

class FlowToStateFlow<T>(flow: Flow<T>, produceValue: () -> T) : StateFlow<T>

Deprecated

Use helpers such as 'mapAsStateFlow' rather than use this class directly. This is only public to allow for the inline function usage below.

A subclass of StateFlow that allows us to turn a Flow into a StateFlow.

Parameters

flow

The Flow that should be converted to a StateFlow

produceValue

The producer of the StateFlow's value

Constructors

Link copied to clipboard
constructor(flow: Flow<T>, produceValue: () -> T)

Properties

Link copied to clipboard
open override val replayCache: List<T>
Link copied to clipboard
open override val value: T

Functions

Link copied to clipboard
open suspend override fun collect(collector: FlowCollector<T>): Nothing
Link copied to clipboard
Link copied to clipboard
fun <T, R> StateFlow<T>.flatMapLatestAsStateFlow(transform: (T) -> StateFlow<R>): StateFlow<R>

Combines a list of StateFlows into another, instead of loosening the result to a Flow.

Link copied to clipboard
fun <T, R> StateFlow<T>.mapAsStateFlow(transform: (T) -> R): StateFlow<R>

Maps one StateFlow into another, instead of loosening it to a Flow.