Skip to content

Instantly share code, notes, and snippets.

@iamchiwon
Created January 26, 2019 04:21
Show Gist options
  • Select an option

  • Save iamchiwon/bd200395a0d0ced65d91d0fa7abe54cb to your computer and use it in GitHub Desktop.

Select an option

Save iamchiwon/bd200395a0d0ced65d91d0fa7abe54cb to your computer and use it in GitHub Desktop.
methodInvoked Example
import RxCocoa
import RxSwift
public extension Reactive where Base: UIViewController {
public var viewDidLoad: ControlEvent<Void> {
let source = self.methodInvoked(#selector(Base.viewDidLoad)).map { _ in }
return ControlEvent(events: source)
}
public var viewWillAppear: ControlEvent<Bool> {
let source = self.methodInvoked(#selector(Base.viewWillAppear)).map { $0.first as? Bool ?? false }
return ControlEvent(events: source)
}
public var viewDidAppear: ControlEvent<Bool> {
let source = self.methodInvoked(#selector(Base.viewDidAppear)).map { $0.first as? Bool ?? false }
return ControlEvent(events: source)
}
public var viewWillDisappear: ControlEvent<Bool> {
let source = self.methodInvoked(#selector(Base.viewWillDisappear)).map { $0.first as? Bool ?? false }
return ControlEvent(events: source)
}
public var viewDidDisappear: ControlEvent<Bool> {
let source = self.methodInvoked(#selector(Base.viewDidDisappear)).map { $0.first as? Bool ?? false }
return ControlEvent(events: source)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment