Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RxCocoa
- import RxSwift
- import UIKit
- extension Reactive where Base: UIView {
- var isFirstResponder: Observable<Bool> {
- return Observable
- .merge(
- methodInvoked(#selector(UIView.becomeFirstResponder)),
- methodInvoked(#selector(UIView.resignFirstResponder))
- )
- .map{ [weak view = self.base] _ in
- view?.isFirstResponder ?? false
- }
- .startWith(base.isFirstResponder)
- .distinctUntilChanged()
- .share(replay: 1)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement