Last active
March 23, 2016 16:27
-
-
Save sergdort/3ea2b5643b1eb1d6865a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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