AnyViewModel
public protocol AnyViewModel
You conform to the AnyViewModel
protocol to define the
model that is used by your view to bind to properties and logic
needed and to handle its lifecycle.
Implement the required ViewType
property to provide the
view type.
-
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
associatedtype ViewType : MwxView
-
The coordinator managing this view model.
Declaration
Swift
var coordinator: AnyCoordinator? { get set }
-
The tab coordinators managed by the managing coordinator of this view model.
Declaration
Swift
var tabCoordinators: [AnyCoordinator]? { get set }
-
Creates an instance of this view model. Required.
Declaration
Swift
init()
-
The function called when the view for this view model appears each time.
Declaration
Swift
func didAppear()
-
The function called when the view for this view model disappears each time.
Declaration
Swift
func didDisappear()
-
Call this function to pop the view for this view model if navigationly pushed.
Note
Only works with link coordinators.Declaration
Swift
func pop()
-
Call this function to dismiss the view for this view model if presented modally.
Note
Only works with sheet coordinators.Declaration
Swift
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
func select(tab selection: Int)
Parameters
selection
A
Int
indicates the selected tab index.
-
root()
Extension methodCall this function to create an instance of a coordinator of root presentation for this view Model type.
Declaration
Swift
static func root()
Return Value
The coordinator instance of this view model type.
-
tab(_:)
Extension methodCall this function to create an instance of a coordinator of tab presentation for this view Model type.
Declaration
Swift
static func tab<V>(_ sender: MwxViewModel<V>) -> MwxCoordinator<Self> where V : MwxView
Parameters
sender
A generic
MwxViewModel
indicates the sender view model for this request.Return Value
The coordinator instance of this view model type.
-
link(_:)
Extension methodCall this function to create an instance of a coordinator of link presentation for this view Model type.
Declaration
Swift
static func link<V>(_ sender: MwxViewModel<V>) -> MwxCoordinator<Self> where V : MwxView
Parameters
sender
A generic
MwxViewModel
indicates the sender view model for this request.Return Value
The coordinator instance of this view model type.
-
sheet(_:)
Extension methodCall this function to create an instance of a coordinator of sheet presentation for this view Model type.
Declaration
Swift
static func sheet<V>(_ sender: MwxViewModel<V>) -> MwxCoordinator<Self> where V : MwxView
Parameters
sender
A generic
MwxViewModel
indicates the sender view model for this request.Return Value
The coordinator instance of this view model type.
-
coordinator(presentation:managingCoordinator:)
Extension methodCreates an instance of a coordinator for this view Model type.
Declaration
Swift
static func coordinator(presentation: MwxPresentation, managingCoordinator: AnyCoordinator? = nil) -> MwxCoordinator<Self>
Parameters
presentation
A
MwxPresentation
indicates the presentation of the coordinator.managingCoordinator
A
AnyCoordinator
indicates managing coordinator of the coordinator.Return Value
The coordinator instance of this view model type.