Created
July 3, 2017 05:44
-
-
Save lvidal1/84d9d13d0dcbd0276fbf91600ba37990 to your computer and use it in GitHub Desktop.
Debounce on typing with Rxjs
This file contains hidden or 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
var input = document.querySelector('input'); | |
var observable = Rx.Observable.fromEvent(input,'input'); | |
observable | |
.map(e => e.target.value) | |
.filter((v)=> v.length > 0) | |
.debounceTime(500) | |
.distinctUntilChanged() | |
.subscribe({ | |
next: function(e){ | |
console.log( | |
e); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment