Created
January 26, 2019 04:21
-
-
Save iamchiwon/bd200395a0d0ced65d91d0fa7abe54cb to your computer and use it in GitHub Desktop.
methodInvoked Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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