Filip Wiesner
01/22/2022, 6:32 PMwithMutableSnapshot
(which has been mentioned here several times) I saw a little note at the end of the doucmentation:
[block] must not suspend if [withMutableSnapshot] is called from a suspend function.Why is that? 🤔 Is it because other code can be run on the same thread when the
block
suspends resulting in other unrelated part of the app being in this snapshot? I am not sure I know enough about Compose and Coroutines to be sure.Adam Powell
01/22/2022, 7:07 PMenter
APIFilip Wiesner
01/22/2022, 7:23 PMvar state by mutableStateOf(0)
val snap = Snapshot.takeMutableSnapshot()
snap.enter { state = 1 }
val result = suspendWhileGettingNumber()
snap.enter {
if (result > 5) state = result
}
snap.apply()
Adam Powell
01/22/2022, 8:35 PM