RxSwiftCommunity/RxGesture is tracked by TopGit as an open-source project, with 1.4k stars on GitHub, written primarily in Swift. RxSwift reactive wrapper for view gestures
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
To run the example project, clone the repo, in the Example folder open RxGesture.xcworkspace.
You might need to run pod install from the Example directory first.
RxGesture allows you to easily turn any view into a tappable or swipeable control like so:
view.rx
.tapGesture()
.when(.recognized)
.subscribe(onNext: { _ in
//react to taps
})
.disposed(by: stepBag)
You can also react to more than one gesture. For example to dismiss a photo preview you might want to do that when the user taps it, or swipes up or down:
rx.gesture is defined as Observable<G> where G is the actual type of the gesture recognizer so what it emits is the gesture recognizer itself (handy if want to call methods like asLocation(in view:) or asTranslation(in view:))
ℹ️ If you use a gesture recognizer alone, prefer the view.rx.fooGesture() syntax over view.rx.anyGesture(.foo()) because it returns the concrete UIGestureRecognizer subclass and avoid you to cast it in subscribe().
Filtering State
By default, there is no filter on the state of the gesture recognizer. That means that you will always receive a first event with the initial state of the gesture recognizer (almost always .possible).
Here are the preferred states that can be used for each kind of gestures (iOS and macOS):
If you are observing multiple gestures at once, you can use the .when() operator if you want to filter against the same state for all gesture recognizers, or use the tuple syntax for individual filtering:
view.rx
.anyGesture(.tap(), .swipe([.up, .down]))
.when(.recognized)
.subscribe(onNext: { gesture in
// Called whenever a tap, a swipe-up or a swipe-down is recognized (state == .recognized)
})
.disposed(by: bag)
view.rx
.anyGesture(
(.tap(), when: .recognized),
(.pan(), when: .ended)
)
.subscribe(onNext: { gesture in
// Called whenever:
// - a tap is recognized (state == .recognized)
// - or a pan is ended (state == .ended)
})
.disposed(by: bag)
The demo app includes examples for all recognizers ➡️ iOS, macOS.
Delegate customization
Lightweight customization
Each gesture recognizer has a default RxGestureRecognizerDelegate. It allows you to customize every delegate method using a policy:
.always will return true to the corresponding delegate method
.never will return false to the corresponding delegate method
.custom takes an associated closure that will be executed to return a value to the corresponding delegate method
Here are the available policies with their corresponding delegate method:
Yes — RxSwiftCommunity/RxGesture ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/RxSwiftCommunity/RxGesture.
What is RxSwiftCommunity/RxGesture?
RxSwiftCommunity/RxGesture (RxSwiftCommunity/RxGesture) is a Swift project on GitHub. From the project's own README: RxSwift reactive wrapper for view gestures
Where do I read more about RxSwiftCommunity/RxGesture?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/RxSwiftCommunity/RxGesture is the definitive source.
Read full README in the tab above.
Still deciding about RxGesture?
One click hands the question to an AI along with this page — see what it says about RxGesture.