How does MVI handle one shot operations like dialogs and toasts?
g
Giorgos Neokleous
11/13/2020, 3:06 PM
@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
Joost Klitsie
11/18/2020, 8:50 AM
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
Rim Gazzah
11/18/2020, 9:21 AM
@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
morganbovi
11/20/2020, 2:51 AM
@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.