getAndUpdate

inline fun <T> MutableStateFlow<T>.getAndUpdate(function: (T) -> T): T

Updates the MutableStateFlow.value atomically using the specified function of its value, and returns its prior value.

function may be evaluated multiple times, if value is being concurrently updated.

Sources

common source
Link copied to clipboard