MwxViewModel

open class MwxViewModel<V> : AnyViewModel where V : MwxView

A piece of view model.

You define the model that is used by your view to bind to properties and logic needed and to handle its lifecycle.

Typealiases

  • The type of view for this view model.

    When you create a custom view model, Swift infers this type from the generic V type property.

    Declaration

    Swift

    public typealias ViewType = V
  • A typealias for the tabCoordinators property.

    Declaration

    Swift

    public typealias MwxTab = AnyCoordinator

Coordinators

  • The coordinator managing this view model.

    Declaration

    Swift

    public var coordinator: AnyCoordinator?
  • The tab coordinators managed by the managing coordinator of this view model.

    Declaration

    Swift

    public lazy var tabCoordinators: [AnyCoordinator]? { get set }

Input & Output

  • The input factory used to generate inputs in this view model.

    Declaration

    Swift

    public var output: MwxOutput
  • The input used to initialize this view model and passed from presenting view models.

    Declaration

    Swift

    public var input: MwxInput

Initialization

  • Creates an instance of this view model Required.

    Declaration

    Swift

    public required init()

Lifecycle

  • The function called when the view for this view model appears each time.

    Declaration

    Swift

    open func didAppear()
  • Define services and corresponding conforming protocols and lifecycle for each service.

    Declaration

    Swift

    open func didDisappear()

Navigation

  • Override this function to define the tab coordinators managed by the managing coordinator of this view model.

    Declaration

    Swift

    open func tabs() -> [MwxTab]

    Return Value

    The tab coordinators managed by the managing coordinator of this view model

  • Call this function to pop the view for this view model if navigationly pushed.

    Note

    Only works with link coordinators.

    Declaration

    Swift

    public func pop()
  • Call this function to dismiss the view for this view model if presented modally.

    Note

    Only works with sheet coordinators

    Declaration

    Swift

    public func dismiss()
  • Call this function to select the tab for this view model if tabs are defined.

    Note

    Only works if tab coordinators defined.

    Declaration

    Swift

    public func select(tab selection: Int)

    Parameters

    selection

    A Int indicates the selected tab index.