Created
October 19, 2015 20:07
-
-
Save mauriciosoares/5f7d185e900a23895e24 to your computer and use it in GitHub Desktop.
rxjs double click example
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
let clickStream = Rx.Observable.fromEvent(document.getElementById('link'), 'click'); | |
clickStream | |
.buffer(clickStream.debounce(250)) | |
.map(list => list.length) | |
.filter(x => x === 2) | |
.subscribe(() => { | |
console.log('doubleclick'); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is simpler imho. Will also fire directly directly after
x
. Only works for double-clicking (not triple click, etc.)