Release 0.7.4 (19)
- Renamed
ViewModel
toBaseViewModel
and made its constructorinternal
- Renamed
BasePresenter
toViewModel
- Renamed
PresenterFactory
toViewModelFactory
- Library now uses more of a "ViewModel" approach to the communication channel between the
View
and the other design pattern components, instead of the previous "Presenter" approach. This removes a cyclic dependence between theView
and the Presenter/ViewModel component.- Previously, the
BasePresenter
had a reference to theView
, and theView
had a reference to thePresenter
. This was needed so that thePresenter
could call theView.render
function with the new derived State, and so theView
could emit intents to the Presenter. This was later abstracted, by having theBasePresenter
only take aFlow<Intent>
instead of aView
, so that there would be no direct reference to the View. These approaches required aPresenterFactory
to simplify the creation of a Presenter, and inject the View it was bound to. - Now, only the
View
has a reference to theViewModel
(previously BasePresenter). TheView
emits intents by calling theViewModel.intent
function. And theView
subscribes to State changes via theViewModel.renderStates
property. This way there is no cyclic dependency requirement between the two components.
- Previously, the
- Created
View.intent
extension function for convenience that just delegates to theViewModel.intent
function.
New usage of the library would look like the following:
class HomeLayout : Layout<HomeIntent, HomeState, HomeChange>() {
override val viewModel = ViewModel<I, S, C>(
perform = { intent, state -> ... },
reduce = { state, change -> ... })
@Composable
override fun Content() {
val state by stateChanges()
Text("State = $state")
}
override fun onBind() {
intent(to HomeIntent.Load())
}
}
Full Changelog: 0.7.3...0.7.4