Mark
05/20/2024, 4:59 AMMutableState.value
should only be set on the UI/Main thread. Is this also true for MutableStateList.add
?shikasd
05/20/2024, 11:13 AMshikasd
05/20/2024, 11:14 AMStylianos Gakis
05/20/2024, 11:20 AMSanpshot.withMutableSnapshot
, will the crash at least be prevented, with the last one applying "winning" or will it crash then too?shikasd
05/20/2024, 11:22 AMMark
05/20/2024, 11:29 AMMutableState.value
or for the MutableStateList.add
? Also, the view model is updating the mutable state in a suspend function, then wouldn’t doing something like withContext(Dispatchers.Main)
be a good way to ensure “you don’t mutate it from multiple threads at the same time”?shikasd
05/20/2024, 11:31 AMOliver.O
05/20/2024, 12:34 PMSnapshot.withMutableSnapshot
?
There's still that warning in the docs, which unfortunately does not provide sufficient details:
Warning: Updating Compose state from a non UI thread without usingAlso discussed here: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1712221343758939?thread_ts=1712066552.382059&cid=CJLTWPH7Smay cause inconsistencies in the state produced.Snapshot.withMutableSnapshot{ }
shikasd
05/20/2024, 1:07 PMshikasd
05/20/2024, 1:18 PMOliver.O
05/20/2024, 3:20 PM