stateFlowOf
fun <S> stateFlowOf(started: SharingStarted = SharingStarted.Eagerly, func: M.() -> S): StateFlow<S>
Creates a StateFlow that maps the current middleware state to a derived state of type S.
This function allows you to observe a specific property or computation based on the current middleware instance. When the middleware state changes, the resulting StateFlow will emit updated values accordingly.
Return
A StateFlow that emits the derived state from the current middleware.
Parameters
S
The type of the state value derived from the middleware.
started
The SharingStarted strategy to control when the flow starts and stops collecting. Defaults to SharingStarted.Eagerly, meaning the flow is always active.
func
A lambda function that extracts the desired state from the middleware instance.