Skip to content

Instantly share code, notes, and snippets.

@Blightwidow
Created February 23, 2018 14:21
Show Gist options
  • Save Blightwidow/81194517bc717b09201bb913e5870543 to your computer and use it in GitHub Desktop.
Save Blightwidow/81194517bc717b09201bb913e5870543 to your computer and use it in GitHub Desktop.
MVVM Router
protocol Router {
func navigate(
to route: Routes,
_ parameters: Any?...
)
}
enum Routes: String {
case date
case home
}
import UIKit
class DateRouter: Router {
weak var view: UIViewController?
func navigate(to route: Routes, _ parameters: Any?...) {
guard let context = view else { return }
switch route {
case .home:
DispatchQueue.main.async {
let destinationVC = viewController(for: route.rawValue)
context.present(destinationVC, animated: true, completion: nil)
}
default:
break
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment