Alexander Maryanovsky
01/20/2024, 1:40 PM@Test
fun testProduceState() {
var inputState by mutableStateOf(true)
rule.setContent {
val outputState by produceState(initialValue = false, inputState) {
value = async(Dispatchers.Default) {
delay(100)
!inputState
}.await()
}
Text("$outputState")
}
rule.onNodeWithText("false").assertExists()
inputState = false
rule.onNodeWithText("true").assertExists()
}
Alexander Maryanovsky
01/20/2024, 1:41 PMZach Klippenstein (he/him) [MOD]
01/20/2024, 6:49 PMAlexander Maryanovsky
01/20/2024, 6:58 PM