ron
06/07/2021, 9:32 PMfun main() {
val _state = MutableStateFlow("")
val state = _state.asStateFlow()
GlobalScope.launch {
while (true) {
_state.emit(Date().toString())
delay(1000)
}
}
GlobalScope.launch {
state.collect {
println("received $it")
}
}
Window {
var text by remember { mutableStateOf(state) }
MaterialTheme {
Text(text.value)
}
}
}
Whatever I try I either run into an exception that the state is out of sync. Or nothing works. I have searched the internet all over, but I have been unable to find anything that sheds any light on what I am trying to do.Adam Powell
06/07/2021, 9:34 PMval text by state.collectAsState()
ron
06/07/2021, 9:36 PM