Giter VIP home page Giter VIP logo

rxviewcontroller's Introduction

RxViewController

Swift CocoaPods Build Status codecov

RxSwift wrapper for UIViewController and NSViewController.

At a Glance

In the view controller:

self.rx.viewDidLoad
  .subscribe(onNext: {
    print("viewDidLoad ๐ŸŽ‰")
  })

APIs

extension Reactive where Base: UIViewController {
  var viewDidLoad: ControlEvent<Void>

  var viewWillAppear: ControlEvent<Bool>
  var viewDidAppear: ControlEvent<Bool>

  var viewWillDisappear: ControlEvent<Bool>
  var viewDidDisappear: ControlEvent<Bool>

  var viewWillLayoutSubviews: ControlEvent<Void>
  var viewDidLayoutSubviews: ControlEvent<Void>

  var willMoveToParentViewController: ControlEvent<UIViewController?>
  var didMoveToParentViewController: ControlEvent<UIViewController?>

  var didReceiveMemoryWarning: ControlEvent<Void>
}
public extension Reactive where Base: NSViewController {
  var viewDidLoad: ControlEvent<Void>

  var viewWillAppear: ControlEvent<Void>
  var viewDidAppear: ControlEvent<Void>

  var viewWillDisappear: ControlEvent<Void>
  var viewDidDisappear: ControlEvent<Void>

  var viewWillLayout: ControlEvent<Void>
  var viewDidLayout: ControlEvent<Void>
}

Installation

  • Using CocoaPods:

    pod 'RxViewController'
  • Using Carthage:

    github "devxoul/RxViewController"
    

Contributing

Any discussions and pull requests are welcomed ๐Ÿ’–

To create a Xcode project:

$ swift package generate-xcodeproj

License

RxViewController is under MIT license. See the LICENSE file for more info.

rxviewcontroller's People

Contributors

bently93 avatar devxoul avatar evfemist avatar murselturk avatar tcldr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rxviewcontroller's Issues

Collision between RxCocoa interception mechanism and KVO.

Trying to subscribe to rx.viewWillAppear on viewDidLoad it's not working.

Debug message is:
"Event error(Collision between RxCocoa interception mechanism and KVO. To resolve this conflict please use this interception mechanism first.")

Support RxSwift 6

This dependency is preventing me from upgrading to RxSwift 6 in my project

RxSwift 6.0 support is invalid

"because RxViewController >=1.0.0 depends on RxExpect 2.0.0..<3.0.0 and RxExpect >=2.0.0 depends on RxSwift 5.0.0..<6.0.0, RxViewController >=1.0.0 requires RxSwift 5.0.0..<6.0.0.
And because root depends on RxSwift 6.0.0..<7.0.0 and root depends on RxViewController 2.0.0..<3.0.0, version solving failed"

it seems it is necessary to temporarily remove RxExpect

No xib or interface builder

I wanted to ask if anyone tried to use it in a UIController without a .xib or interface builder screen. I am trying to use it on custom classes but after subscribing to any method nothing is happening.

Access UIBarButtonItems tap?

Hi! Would it be possible to extend RxViewController tap events of the optional leftBarButtonItem and rightBarButtonItem?

    var leftBarButtonTapped: Driver<Void> { get }
    var rightBarButtonTapped: Driver<Void> { get }

It would be awesome to listen to these!

isVisible does not always work if not subscribed immediately

Hello,

thank you very much for this great Pod. I think there might be an issue with UIViewController isVisible property.
For instance, if this Observable is not subscribed to before the base method viewWillAppear() is invoked for the first, time, then isVisible will emit nothing instead of emitting true.

My point is that isVisible should behave like a state, not just like a combination of events: any time some observer subscribes to it, it should immediately get an event true or false.
To do so, there would be two things to do:

  • using a .share(replay: 1, scope: .forever) and a .startWith(false).
  • subscribing it internally, so that is begins immediately to listen for the viewDidAppearObservable and viewWillDisappearObservable, even if externally there are no subscribers to it. Maybe using a .publish() and .connect(), or using an internal DisposeBag property.

Thank you very much, I would be pleased to know your opinion on this.

P.S. : And to go a bit further, it might be interesting to expose it as a Driver instead of an Observable.

`rx.viewDidLoad` not work.

I used it with ReactorKit followed your excellent App Drrrible

Here's my code:

final class HomeViewController: BaseViewController, StoryboardView {

        override func viewDidLoad() {
                super.viewDidLoad()
                print("viewDidLoad normal ๐ŸŽ‰")
        }

        func bind(reactor: HomeViewReactor) {
                self.rx.viewDidLoad
                        .subscribe(onNext: {
                                print("viewDidLoad Rx ๐ŸŽ‰")
                        })
                        .disposed(by: disposeBag)

                self.rx.viewWillAppear.map { $0 }
                        .subscribe(onNext: {
                                print("viewWillAppear \($0)๐ŸŽ‰")
                        })
                        .disposed(by: disposeBag)
        }
}

Here's console outputs:

viewDidLoad normal ๐ŸŽ‰
viewWillAppear false๐ŸŽ‰

The rx.viewDidLoad did not trigger, did I miss something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.