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 : RouterParameters
routerThe source router.
-
Triggers routes and provides the transition context in the completion-handler.
Useful for deep linking. It is encouraged to use
triggerinstead, if the context is not needed.Declaration
Swift
public func contextTrigger(_ route: RouteType, with options: TransitionOptions, completion: ContextPresentationHandler?)Parameters
routeThe route to be triggered.
optionsTransition options configuring the execution of transitions, e.g. whether it should be animated.
completionIf present, this completion handler is executed once the transition is completed (including animations). If the context is not needed, use
triggerinstead. -
Triggers the specified route by performing a transition.
Declaration
Swift
public func trigger(_ route: RouteType, with options: TransitionOptions, completion: PresentationHandler?)Parameters
routeThe route to be triggered.
optionsTransition options for performing the transition, e.g. whether it should be animated.
completionIf 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
presentableThe context in which the presentable is shown. This could be a window, another viewController, a coordinator, etc.
nilis 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()
View on GitHub
StrongRouter Class Reference