StrongRouter
StrongRouter is a type-erasure of a given Router object and, therefore, can be used as an abstraction from a specific Router implementation without losing type information about its RouteType.
StrongRouter abstracts away any implementation specific details and
essentially reduces them to properties specified in the Router
protocol.
Note
Do not hold a reference to any router from the view hierarchy. UseUnownedRouter
or WeakRouter
in your view controllers or view models instead.
You can create them using the Coordinator.unownedRouter
and Coordinator.weakRouter
properties.
-
Creates a StrongRouter object from a given router.
Declaration
Swift
public init<T>(_ router: T) where RouteType == T.RouteType, T : Router
Parameters
router
The source router.
-
Triggers routes and provides the transition context in the completion-handler.
Useful for deep linking. It is encouraged to use
trigger
instead, if the context is not needed.Declaration
Swift
public func contextTrigger(_ route: RouteType, with options: TransitionOptions, completion: ContextPresentationHandler?)
Parameters
route
The route to be triggered.
options
Transition options configuring the execution of transitions, e.g. whether it should be animated.
completion
If present, this completion handler is executed once the transition is completed (including animations). If the context is not needed, use
trigger
instead. -
Triggers the specified route by performing a transition.
Declaration
Swift
public func trigger(_ route: RouteType, with options: TransitionOptions, completion: PresentationHandler?)
Parameters
route
The route to be triggered.
options
Transition options for performing the transition, e.g. whether it should be animated.
completion
If present, this completion handler is executed once the transition is completed (including animations).
-
This method is called whenever a Presentable is shown to the user. It further provides information about the presentable responsible for the presenting.
Declaration
Swift
public func presented(from presentable: Presentable?)
Parameters
presentable
The context in which the presentable is shown. This could be a window, another viewController, a coordinator, etc.
nil
is specified whenever a context cannot be easily determined. -
The viewController of the Presentable.
In the case of a
UIViewController
, it returns itself. A coordinator returns its rootViewController.Declaration
Swift
public var viewController: UIViewController! { get }
-
Declaration
Swift
public func registerParent(_ presentable: Presentable & AnyObject)
-
Declaration
Swift
public func childTransitionCompleted()