Hi, I'm working with compose-desktop and coroutine...
# coroutines
g
Hi, I'm working with compose-desktop and coroutines. I am updating app state through a StateFlow and am a little confused about what thread the StateFlow needs to be updated on. For example, a user enters some text, a coroutine is launched to save the text to the database, then a new state object is created with the new text, the state object is then added to the StateFlow, the composable listening to the StateFlow is updated. The last part, when the state object is added to StateFlow, does that need to happen on Dispatchers.UI in stead of Dispatchers.Main because the UI will be updated?
a
No, StateFlow is thread-safe to write to and compose's default collectAsState extensions collect on the recomposer's effect dispatcher. You're good to go.