Skip to content

//reactivestate-compose/com.ensody.reactivestate.compose/withSetter

withSetter

[common]\

@Composable

fun <T> MutableState<T>.withSetter(setter: MutableState<T>.(T) -> Unit): MutableState<T>

Returns a new MutableState that calls setter instead of doing the actual value update.

IMPORTANT: You must manually set value = on the underlying MutableState. The setter gets the underlying MutableState via this.

This can be used to wrap a MutableState with extra update logic. For simpler use cases you might prefer beforeUpdate/afterUpdate instead.