Skip to content

Instantly share code, notes, and snippets.

@sergdort
Last active March 23, 2016 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergdort/3ea2b5643b1eb1d6865a to your computer and use it in GitHub Desktop.
Save sergdort/3ea2b5643b1eb1d6865a to your computer and use it in GitHub Desktop.
class ViewController: UIViewController {
let disposeBag = DisposeBag()
@IBOutlet var pushButton: UIButton!
@IBOutlet var presentButton: UIButton!
@IBOutlet weak var dismissButton: UIButton!
var voidSegue: ModalSegue<ViewController, SecondViewController, Void> {
return ModalSegue(fromViewController: self,
toViewControllerFactory: { (sender, context) -> SecondViewController in
return SecondViewController()
})
}
var profileSegue: NavigationSegue<UINavigationController,
ProfileViewController,
ProfileViewModel> {
return NavigationSegue(fromViewController: self.navigationController!,
toViewControllerFactory: { (sender, context) -> ProfileViewController in
let profileViewController: ProfileViewController = ...
profileViewController.profileViewModel = context
return profileViewController
})
}
override func viewDidLoad() {
super.viewDidLoad()
presentButton.rx_tap
.bindTo(voidSegue)
.addDisposableTo(disposeBag)
pushButton.rx_tap
.map {
return ProfileViewModel(name: "John Doe",
email: "JohnDoe@example.com",
avatar: UIImage(named: "avatar"))
}
.bindTo(profileSegue)
.addDisposableTo(disposeBag)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment