--

For the record, a race condition can only happen if multiple threads try to update the StateFlow at the same time using a non-atomic operation, which is not the case in your example because viewModelScope always uses the main thread (unless you explicitly override the dispatcher).

--

--

Christophe Beyls
Christophe Beyls

Written by Christophe Beyls

Android developer from Belgium, blogging about advanced programming topics.

Responses (1)