Skip to content
Adam Share edited this page Oct 5, 2020 · 9 revisions

Scope Presenter Interactor Router

App architecture utilizing Lifecycle to create a scoped business logic tree independent of the view hierarchy.

Presenter ViewLifecycleOwner that provides a View to the parent scope and can be referenced as an ObservableObject by the returned view.
Interactor LifecycleOwner that contains business logic and optionally a strong reference to a Router and Presenter.
Router LifecycleDependent that encapsulates and generalizes routing logic between scopes.

What are the main difference between SPIR and RIBs?

  • Router is optional because the ScopeLifecycle is owned by the Interactor which manages both lifecycle state and attaching child scopes.
  • Router does not have a circular reference to an Interactor and instead instantiates with the shared ScopeLifecycle as a LifecycleDependent enabling it to also conform to LifecycleOwnerRouting.
  • Worker is no longer needed since an Interactor can encapsulate business logic as a child of another Interactor.
  • Presenter Interactor and Router logic can live in one PresentableInteractor to start and refactor as you scale up.
  • Builder classes are provided as a convenience for type erasure without requiring subclassing keeping leaf scopes lightweight.