beforeUpdate

fun <T> MutableStateFlow<T>.beforeUpdate(setter: (T) -> Unit): MutableStateFlow<T>

Returns a new MutableStateFlow that calls setter before doing the actual value update.

The value is set automatically for you after setter has been called. For more control use withSetter. This can be used to wrap a StateFlow/MutableStateFlow with extra update logic.