Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/RxSwiftCommunity/RxSegue
https://github.com/RxSwiftCommunity/RxSegue
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/RxSwiftCommunity/RxSegue
- Owner: RxSwiftCommunity
- License: mit
- Created: 2016-03-19T11:32:26.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-11-27T05:27:47.000Z (about 7 years ago)
- Last Synced: 2024-11-11T18:32:18.070Z (2 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.[![Build Status](https://travis-ci.org/RxSwiftCommunity/RxSegue.svg?branch=master)](https://travis-ci.org/RxSwiftCommunity/RxSegue)
[![Version](https://img.shields.io/cocoapods/v/RxSegue.svg?style=flat)](http://cocoapods.org/pods/RxSegue)
[![License](https://img.shields.io/cocoapods/l/RxSegue.svg?style=flat)](http://cocoapods.org/pods/RxSegue)
[![Platform](https://img.shields.io/cocoapods/p/RxSegue.svg?style=flat)](http://cocoapods.org/pods/RxSegue)## Usage
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Example
![RxSegueExample](https://github.com/RxSwiftCommunity/RxSegue/blob/master/RxSegueExample.gif)
```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.