Presenters depend on a view interface. Extend View for simple attachable elements or Viewable when you expose a DominoElement.
public interface DashboardView extends View, DashboardUiHandlers.HasUiHandlers {
void showMessage(String text);
void showUser(String userId);
}
Annotate the implementation with @UiView. The processor generates the binding and Dagger module to inject the view into presenters.
@UiView
public class DashboardViewImpl extends BrixView<Element, DashboardUiHandlers>
implements DashboardView {
@Handlers DashboardUiHandlers handlers;
@Inject
DashboardViewImpl() { setText("Loading..."); }
@Override public void showMessage(String text) { setText(text); }
@Override public void showUser(String userId) { handlers.onRefreshUser(userId); }
}
Define UI handler interfaces and mark presenter methods with @UiHandler. The generated handler bridges view events to the presenter.
public interface DashboardUiHandlers extends UiHandlers {
void onRefresh();
void onRefreshUser(String userId);
interface HasUiHandlers { void setUiHandlers(DashboardUiHandlers handlers); }
}
@BrixPresenter
public class DashboardPresenter extends Presenter<DashboardView>
implements DashboardUiHandlers {
@UiHandler public void onRefresh() { /* presenter logic */ }
@UiHandler public void onRefreshUser(String userId) { /* presenter logic */ }
}
When a presenter uses @RegisterSlots, the processor generates a *Slots interface. Make your view implement it to supply slot instances so the presenter can register them during activation.
Use BrixView or your own View/Viewable implementations. Attach/detach callbacks from IsAttachable allow presenters to react to DOM lifecycle, and implementing CanConfirmNavigation lets the view block navigation while dirty.