Should MviPresenter offer getViewStateObservable() or not?
See original GitHub issueThe idea of MviPresenter.getViewStateObservable()
is that another MVI UI component could use this observable as “intent” for rendering it’s own view state.
i.e: AView has APresenter. BView has BPresenter that takes APresenter.getViewStateObservable()
as input (i.e. as intent) to coordinate BView
. In other words: Changing AView
has impact to what BView
displays.
However, I think that usually both UI components should rather “observe” both the same “model” from business logic. Offering getViewStateObservable()
may lead to the wrong impression that getViewStateObservable()
should be used everywhere. Actually, I think that there are only very few edge cases where using MviPresenter.getViewStateObservable()
makes sense and should be preferred over “observing the same model”.
Furthermore, parent - child relations are not a good idea and MviPresenter.getViewStateObserable()
allows you to build such parent-child relations (attention: cycles in your dependency graph).
As compromise we could move getViewStateObservable()
to MviBasePresenter
(rather than MviPresenter
and make getViewStateObservable()
protected.
By doing so a developer explicitly has to override getViewStateObservable()
with public
visibility in his own presenter to make getViewStateObservable()
visible for other presenters (to establish a child-parent relationship).
Note: child-parent relation may not be the correct word because there is no Presenter.getParentPresenter()
method etc. so that is not really a parent - child relation from a hierarchical point of view, but I hope you get what I’m trying to say with “parent-child” relation.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
oops, forgot to update this:
Finally I have changed mind again:
getViewStateObservable()
hasprotected
visibility in3.0
.Testing can be done easily even without
getViewStateObservable()
I have changed mind :
getViewStateObservable()
has public visibility in upcoming3.0
release.Mainly for unit testing reasons: now you can simply write unit tests for presenter by accessing the presenters observable which makes unit testing more convenient.