Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think I found my own answer. The main problem seems to be that all of the simple code examples make the <em>Activities</em> be the <em>Presenters</em>, as in:</p> <pre><code>public class NavigationActivity extends AbstractActivity implements NavigationView.Presenter { private final ClientFactory clientFactory; private final NavigationPlace place; public NavigationActivity(ClientFactory clientFactory, NavigationPlace place) { this.clientFactory = clientFactory; this.place = place; } @Override public void start(AcceptsOneWidget panel, EventBus eventBus) { NavigationView navView = clientFactory.getNavigationView(); navView.setSearchTerm(place.getSearchTerm()); navView.setPresenter(this); panel.setWidget(navView); } @Override public void goTo(Place place) { clientFactory.getPlaceController().goTo(place); } } </code></pre> <p>Now Activities are fairly short-lived, whereas a typical Presenter in the 'classical' sense has a much longer lifespan in order to maintain the binding between the model and the UI. So what I did was to implement a separate Presenter using the standard MVP design pattern, and all the Activity does is something like this:</p> <pre><code>public class NavigationActivity extends AbstractActivity { private final ClientFactory clientFactory; private final NavigationPlace place; public NavigationActivity(ClientFactory clientFactory, NavigationPlace place) { this.clientFactory = clientFactory; this.place = place; } @Override public void start(AcceptsOneWidget panel, EventBus eventBus) { NavigationPresenter presenter = clientFactory.getNavigationPresenter(); presenter.setSearchTerm(place.getSearchTerm()); presenter.go(panel); } } </code></pre> <p>So, instead of the Activity fetching the <em>View</em>, and acting like a Presenter on it, it fetches the <em>actual</em> Presenter, just informs it of the client state change induced by the Place, and tells it where to display its information (i.e. the view). And the Presenter is then free to manage the view and the model any way it likes - this way works a lot better (at least with what I have in mind for the application I'm working on) than the code examples I have found so far.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload