withSetter
fun <T> MutableStateFlow<T>.withSetter(setter: MutableStateFlow<T>.(T) -> Unit): MutableStateFlow<T>
Returns a new MutableStateFlow that calls setter instead of doing the actual value update.
IMPORTANT: You must manually set value =
on the underlying MutableStateFlow. The setter gets the underlying MutableStateFlow via this
.
This can be used to wrap a MutableStateFlow with extra update logic. For simpler use cases you might prefer beforeUpdate/afterUpdate instead.