Idrees Khan
Idrees Khan

Reputation: 7752

Ionic 2 Debounce on Gesture Event

How to bind Rx/Js denounce to ionic 2 gesture event ?

        this.pressGesture = new Gesture(this.content._elementRef.nativeElement);
        this.pressGesture.listen();
        this.pressGesture.on('pinch', e => { 
            console.log('testing');
        });

Upvotes: 0

Views: 639

Answers (1)

paulpdaniels
paulpdaniels

Reputation: 18663

You are looking for something like this:

const pinch = Observable.fromEvent(this.pressGesture, 'pinch')
  .debounceTime(500);

The fromEvent method accepts types that conform to standard EventEmitter like interfaces and as such is able to automatically bind the event using the on method. This lifts the Gesture object into a stream and allows you to use the standard RxJS operators on it.

Upvotes: 2

Related Questions