replaceAndGet
This is a version of updateAndGet.
This is a simple helper for the common case where you want to copy()
a data class:
data class Foo(val num: Int)
val stateFlow = MutableStateFlow(Foo(3))
val newValue = stateFlow.replaceAndGet { copy(num = 5) }
Content copied to clipboard
Return
The new value after replacing.