https://github.com/RxSwiftCommunity/RxSegue
https://github.com/RxSwiftCommunity/RxSegue
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/RxSwiftCommunity/RxSegue
- Owner: RxSwiftCommunity
- License: mit
- Created: 2016-03-19T11:32:26.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-11-27T05:27:47.000Z (over 7 years ago)
- Last Synced: 2024-11-11T18:32:18.070Z (5 months ago)
- Language: Swift
- Size: 1.87 MB
- Stars: 80
- Watchers: 29
- Forks: 18
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rxswift - RxSegue
README
# RxSegue
### Reactive generic segue, implemented with RxSwift.[](https://travis-ci.org/RxSwiftCommunity/RxSegue)
[](http://cocoapods.org/pods/RxSegue)
[](http://cocoapods.org/pods/RxSegue)
[](http://cocoapods.org/pods/RxSegue)## Usage
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Example

```swift
class ViewController: BaseViewController {
let disposeBag = DisposeBag()
@IBOutlet var pushButton: UIButton!
@IBOutlet var presentButton: UIButton!
@IBOutlet weak var dismissButton: UIButton!var voidSegue: AnyObserver {
return ModalSegue(fromViewController: self,
toViewControllerFactory: { (sender, context) -> SecondViewController in
return SecondViewController()
}).asObserver()
}var profileSegue: AnyObserver {
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](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod "RxSegue"
```## License
RxSegue is available under the MIT license. See the LICENSE file for more info.