Now to pass some arguments to ViewModel we have to include them into the initialState
, like in the example below.
data class MyState(val foo: Int) : MvRxState {
constructor(args: MyArgs) : this(args.foo)
}
It works well in the simple examples, but sometimes we need some info that does not need to be rendered. An api parameter, some userId
, for example. We have to use "dead" fields in state that make no sense for the View and only needed to construct a ViewModel or perform background operations.
@Parcelize
data class MyArgs(val userId: String)