Created
April 27, 2021 06:57
-
-
Save kyungpyoda/e5b0c78619911ab596504962e2bf60b8 to your computer and use it in GitHub Desktop.
RxSwift custom LongPress gesture
This file contains 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 RxSwift | |
extension Reactive where Base: UIButton { | |
var longPress: Observable<Int> { | |
return controlEvent(.touchDown) | |
.flatMapLatest { _ in | |
Observable.timer(.milliseconds(500), scheduler: MainScheduler.instance) | |
.takeUntil(self.controlEvent(.touchUpInside)) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment