RxSwiftCommunity / Rxsegue
Licence: mit
Stars: ✭ 82
Programming Languages
swift
15916 projects
RxSegue
Reactive generic segue, implemented with RxSwift.
Usage
To run the example project, clone the repo, and run pod install
from the Example directory first.
Example
class ViewController: BaseViewController {
let disposeBag = DisposeBag()
@IBOutlet var pushButton: UIButton!
@IBOutlet var presentButton: UIButton!
@IBOutlet weak var dismissButton: UIButton!
var voidSegue: AnyObserver<Void> {
return ModalSegue(fromViewController: self,
toViewControllerFactory: { (sender, context) -> SecondViewController in
return SecondViewController()
}).asObserver()
}
var profileSegue: AnyObserver<ProfileViewModel> {
return NavigationSegue(fromViewController: self.navigationController!,
toViewControllerFactory: { (sender, context) -> ProfileViewController in
let profileViewController: ProfileViewController = ...
profileViewController.profileViewModel = context
return profileViewController
}).asObserver()
}
override func viewDidLoad() {
super.viewDidLoad()
presentButton.rx.tap
.bindTo(voidSegue)
.addDisposableTo(disposeBag)
pushButton.rx.tap
.map {
return ProfileViewModel(name: "John Doe",
email: "[email protected]",
avatar: UIImage(named: "avatar"))
}
.bindTo(profileSegue)
.addDisposableTo(disposeBag)
}
}
Installation
RxSegue is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "RxSegue"
License
RxSegue is available under the MIT license. See the LICENSE file for more info.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].