Routable
public protocol Routable : AnyObject
A protocol that all navigable ViewControllers should adhere to.
The UINavigationController and the UITabBarController should NOT adhere to this protocol.
-
The identifier associated to the routable element.
extension ProfileViewController: Routable { var screenIdentifier: ScreenIdentifier { "profile" } }Declaration
Swift
static var screenIdentifier: ScreenIdentifier { get } -
assign(model:)Default implementationDue to limitations with generics, and the inability to leverage
Type Erasurein this specific case, It is impossible to automatically cast an extractedRoutableViewControllerto its right type, preventing the automatic assignment of the passed viewmodel to the view controller. To work around it,assign(model: Any) -> Boolis introduced and should be used as follow:func assign(model: Any) -> Bool { guard let model = model as? DemoViewModel else { return false } self.viewModel = model return true }Default Implementation
Declaration
Swift
@discardableResult func assign(model: Any) -> Bool
View on GitHub
Routable Protocol Reference