Just published a blog post about MVI architecture ...
# android-architecture
r
Just published a blog post about MVI architecture with android using kotlin with a github simple repo as well, constructive feedbacks are welcome 😃 : https://rimgazzeh.medium.com/mvi-architecture-with-android-fcde123e3c4a
🙌 1
👍 5
p
How does MVI handle one shot operations like dialogs and toasts?
g
@Prithivraj Selvaraj you can represent that as part of the state. A good example (not in kotlin or coroutines) but enough to convey what to do with snackbar. http://hannesdorfmann.com/android/mosby3-mvi-7
j
I have a question: Why is the initData on the view level? Views have a tendency to recreate themselves, but viewModels do not. Would it not make sense to have a point of initialization in the ViewModel?
r
@Joost Klitsie the function initData in the View parse the data coming from the viewModel into the ui and not where I get the data from the API, just to not put all the logic in the onCreate, it’s more clear to put the initUI, initData and initEvent apart in a funtion each, although it always depend on your needs how you separate you logic
m
@Prithivraj Selvaraj late reply but I like to use another stream for one off events. Dialogs, toasts and even navigation. It can be a part of the state but you end up doing all sorts of checks to see if you should repeat it in different situations. I am of the opinions that most of these are likely not permanent state and if they are then they should be in the state.