RxSegue

Reactive generic segue. Implemented with RxSwift. Abstracts navigation logic ```swift var profileSegue: NavigationSegue<UINavigationController, ProfileViewController, ProfileViewModel> { return NavigationSegue(fromViewController: self.navigationController!, toViewControllerFactory: { (sender, context) -> ProfileViewController in let profileViewController: ProfileViewController = ... profileViewController.profileViewModel = context return profileViewController }) } //---------- pushButton.rx_tap .map { return ProfileViewModel(name: "John Doe", email: "JohnDoe@example.com", avatar: UIImage(named: "avatar")) } .bindTo(profileSegue) .addDisposableTo(disposeBag) ```

Showing:

Popularity

Downloads/wk

0

GitHub Stars

82

Maintenance

Last Commit

4yrs ago

Contributors

7

Package

Dependencies

1

License

MIT

Categories

Readme

RxSegue

Reactive generic segue, implemented with RxSwift.

Build Status Version License Platform

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Example

RxSegueExample

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: "JohnDoe@example.com",
                    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.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100