suika
10/12/2025, 7:37 AM@Test
fun test19() {
Snapshot.registerGlobalWriteObserver {
println("$it") // MutableState(value=10)@
Snapshot.sendApplyNotifications()
}
Snapshot.registerApplyObserver { set, _ ->
println(set.joinToString()) // !!! Expected MutableState(value=10)@, but it wasn't printed.
}
val snapshot1 = Snapshot.takeMutableSnapshot()
var state: MutableState<Int>? = null
snapshot1.enter {
state = mutableStateOf(0)
thread {
println(state.value) // 0
state.value = 10
}.join()
}
println(state?.value) // 10
snapshot1.apply().check()
println(state?.value) // 10
}shikasd
10/12/2025, 10:07 PMsuika
10/13/2025, 6:30 AMshikasd
10/13/2025, 12:05 PMwithMutableSnapshot if they happen on background thread to resolve some of the shortcomings hereshikasd
10/13/2025, 12:06 PMsuika
10/13/2025, 12:46 PM