Skip to content

Presenter revealing

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

Revealing is the process of showing up the view in the application UI, it is normally when the view is attached to the application UI, the revealing is not affected by view visibility as we can reveal views in hidden state, but as long as the view become part of the application UI it is considered revealed - In browser this means the view elements are attached to the DOM -.

The revealing is only for presenters that inherits from the ViewBaseClientPresenter, and revealing a view is part of the presenter life cycle as we discussed before, In Domino-mvp we have two options to reveal a presenter view, Auto and Manual, Auto revealing means the view will be revealed as soon as the presenter is activated, while manual means it is our job to decide when to reveal the view after the presenter is activated, for example the presenter is activated, but then we wait for an event to reveal the view, or we might be waiting for response from the server.

For automatic revealing we use the annotation @AutoReveal on the proxy, like the following :

import org.dominokit.domino.api.client.annotations.presenter.AutoReveal;

@PresenterProxy
@AutoRoute(token = "books/:bookId")
@AutoReveal
public class BookProxy extends ViewBaseClientPresenter<BookView> {

}
  • Reveal condition :

    We can use the @RevealCondition to conditionally control auto revealing of a presenter, we annotate a method that returns a boolean to be evaluated before revealing the view if it returns true the auto reveal happens, otherwise the view will not, example :

    import org.dominokit.domino.api.client.annotations.presenter.RevealCondition;
    import org.dominokit.domino.api.client.annotations.presenter.AutoReveal;
    
    @PresenterProxy
    @AutoRoute(token = "books/:bookId")
    @AutoReveal
    public class BookProxy extends ViewBaseClientPresenter<BookView> {
    
        @RevealCondition
        public boolean shouldReveal() {
            // true  : will reveal the view.
            // false : view will not be automatically revealed
            return true;
        }
    }
  • Manual revealing :

    To manually revealing a presenter we will just need to call its public method reveal().