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.
-
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
-
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 }
-
Creates an instance of this view model Required.
Declaration
Swift
public required init()
-
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()
-
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 coordinatorsDeclaration
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.