Skip to content

BaseClientPresenter

Ahmad K. Bawaneh edited this page Nov 7, 2021 · 1 revision

Passive or Simple presenters

Passive presenters are not linked with a view or any UI elements, they are just classes that can be controlled by routing but, they will work in the background to do some tasks, they do not control any view life-cycle but, they can listen to events, make calls to the server and manipulate the navigation tokens, we can create such a presenter by extending BaseClientPresenter and annotate the class with @Presenter

@Presenter
public class SimplePresenter extends BaseClientPresenter {
  @Override
  protected void onActivated() {
    
  }

  @Override
  protected void onDeactivated() {

  }

  @Override
  public Optional<String> getName() {
    return Optional.of("simplePresenter");
  }

}

The only interesting super methods in such a presenter are the postConstruct and onActivated methods, those methods are coupled to the presenter life-cycle in domino-mvp, for such a presenter the life-cycle is as the following :

  1. Some routing happens that requires the presenter to be activated.

    We will discuss more about how presenters can be activated later.

  2. A new instance of the presenter will be created

    Presenters can be marked as singleton, singleton presenter will utilize any already created instance.

  3. Call postConstruct method. - For singleton presenter this will be called only once when we create the first instance -

  4. Register presenter events listeners.

  5. Fire presenter state event if such event is present. - we can make the presenter fire an event when ever its (de)activated -

  6. If the presenter has a name we register that presenter name in an internal registry.

  7. Call onActivated method.

  8. Later, when the presenter is deactivated.

  9. Call onDeactivated