Learn

Lifecycle and ownership

Understand PresenterSession states, Model transitions, invalidation, closure, and the ownership boundary around business objects.

v0.1.0-dev.1Advanced

Lifecycle and ownership

One Presenter instance belongs to one session.

text
created → active → closing → closed

Attachment order

  1. Create Presenter and attach the initial Model.
  2. Subscribe to invalidations and effects.
  3. Start the session and invoke onModelAttached once.
  4. Build the initial ViewState.

Subscribing before start() is essential because onModelAttached may invalidate presentation or emit an initial effect.

Model transitions

updateModel(current) stores the current Model before calling onModelChanged(previous, current). Every change signal creates a transition; Ark MVP does not discard equal Models because application equality may omit information important to presentation.

Rebuilding ViewState

The host asks Presenter to rebuild when Model changes, Presenter calls invalidateView(), or the presentation environment changes. buildViewState must derive data only; it must not dispatch commands, navigate, or emit effects.

Closing

close() invokes closePresenter() once and closes output channels even if Presenter cleanup fails. A closed Presenter cannot be attached again. Reuse would carry stale state and subscriptions across feature boundaries.

Ownership table

ResourceOwner
UseCase, state manager, Repository-facing coordinatorApplication composition
ModelBindingThe object that created the binding
Presenter and Presenter-local resourcesPresenterSession or MvpView
Flutter controllers and animation resourcesRendering StatefulWidget

Closing a View closes Presenter, not the business sources captured by ModelBinding.

ARKTELOS

Purpose-built engineering systems for software that has to hold.