benkuly
03/03/2023, 7:35 AMAccess from different threads is detected, must be on the main thread only.Current thread: AWT-EventQueue-0 @coroutine#5082. First thread: AWT-EventQueue-0 @coroutine#11.
Thown here:
withContext(Dispatchers.Main.immediate) {
push(configuration, onComplete) // <--
}
Any idea what's the problem?Arkadii Ivanov
03/03/2023, 8:31 AMbenkuly
03/03/2023, 8:38 AMwithContext(Dispatchers.Main.immediate)
Notice: It is common test-code. Therefore only a few view models are created...Arkadii Ivanov
03/03/2023, 8:39 AMbenkuly
03/03/2023, 8:41 AMArkadii Ivanov
03/03/2023, 8:42 AMEvegenii Khokhlov
03/03/2023, 9:20 AMkotlinx-coroutines-test
has very handy Dispatchers.setMain()
method.Arkadii Ivanov
03/03/2023, 9:21 AMbenkuly
03/03/2023, 9:26 AMDispatchers.setMain()
and don't using real main dispatchers was the trick. Thank you 🙂