MvRx makes handling configuration changes manually a thing of the past. By using the property delegate
fragmentViewModel(), MvRx will handle configuration changes for you. No more parceling of data into bundles in onSaveInstanceState!
This lesson will also introduce the concept of invalidate() which will be called any time the state of any of your ViewModels change.
Hello Gabriel, Thanks for this awesome course.
It is very interesting for Fragments. Looks very easy.
About Activities, I found that I need my Activity to extend "BaseMvRxActivity()".
But what about state management? Is there similar delegation to replace this initialization similar to what you did for fragment?
private var viewModel = MainViewModel(MainState())
Thanks a lot.
I think I found something.
I need to replace above line with: private val viewModel: LoginViewModel by activityViewModel()
However, my new issue is, activityViewModel, cannot be imported by Android Studio.
I have a trouble, my State is a Sealed Class and when I declare the viewModel as fragmentViewModel I get the next error:
Caused by: java.lang.IllegalStateException: Attempt to create the MvRx state class SearchState has failed. One of the following must be true: 1), 2) 3)
Can I use Sealed Class as MvRxState?
Thanks in advance.