updateAs

inline fun <R> MutableStateFlow<*>.updateAs(block: R.() -> R)

Applies block to a MutableStateFlow<*>'s current value as if it were statically typed MutableStateFlow<R> — for call sites holding a type-erased state flow (e.g. a sealed UI-state flow narrowed to one specific subtype at a given point) that still want a type-safe update {}. A no-op if the flow's current value isn't actually non-null (via withNotNull) — this doesn't itself verify the value is really an instance of R; an unchecked cast that doesn't hold throws inside block.

Parameters

block

transforms the current value of type R into its next value.