-
-
Notifications
You must be signed in to change notification settings - Fork 7
BaseClientPresenter
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 :
-
Some routing happens that requires the presenter to be activated.
We will discuss more about how presenters can be activated later.
-
A new instance of the presenter will be created
Presenters can be marked as singleton, singleton presenter will utilize any already created instance.
-
Call
postConstruct
method. - For singleton presenter this will be called only once when we create the first instance - -
Register presenter events listeners.
-
Fire presenter state event if such event is present. - we can make the presenter fire an event when ever its (de)activated -
-
If the presenter has a name we register that presenter name in an internal registry.
-
Call
onActivated
method. -
Later, when the presenter is deactivated.
-
Call
onDeactivated