Skip to content

Instantly share code, notes, and snippets.

@burnoo
Created April 4, 2022 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save burnoo/30c6915cc06c361d2b49a950147be684 to your computer and use it in GitHub Desktop.
Save burnoo/30c6915cc06c361d2b49a950147be684 to your computer and use it in GitHub Desktop.
Two-way data binding in Jetpack Compose 4
@Composable
fun <T> MutableStateFlow<T>.collectAsMutableState(
context: CoroutineContext = EmptyCoroutineContext
): MutableState<T> = MutableStateAdapter(
state = collectAsState(context),
mutate = { value = it }
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment