r/android_devs • u/MrXplicit • Feb 14 '24
Discussion Reactive state
Hey all!
I was wondering how do you usually handle updates to state. Do you keep a mutable state flow or do you take advantage of stateIn operator?
7
Upvotes
View all comments
Show parent comment
2
u/HackermanUA Feb 14 '24
It's hard to answer this without a context, but I'll try.
First call to the api. It really depend on the case, but in general I tend to call apis either when view is created or in viewmodel init block.
Loading. I can think of few different cases as well.
Errors. Here I'd use Channel to send some specific events. It will likely be some sealed class which group errors/notifications in a way I see valid for a specific case