getAndReplace
A version of getAndUpdate where the current value is passed via this.
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 oldValue = stateFlow.getAndReplace { copy(num = 5) }Content copied to clipboard
Return
The previous value before replacing.