-
-
Save burnoo/29be79794da6de7bfb76f6df2ea158f3 to your computer and use it in GitHub Desktop.
Two-way data binding in Jetpack Compose 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MutableStateAdapter<T>( | |
private val state: State<T>, | |
private val mutate: (T) -> Unit | |
) : MutableState<T> { | |
override var value: T | |
get() = state.value | |
set(value) { | |
mutate(value) | |
} | |
override fun component1(): T = value | |
override fun component2(): (T) -> Unit = { value = it } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment