Skip to content

Instantly share code, notes, and snippets.

@lvidal1
Created July 3, 2017 05:44
Show Gist options
  • Save lvidal1/84d9d13d0dcbd0276fbf91600ba37990 to your computer and use it in GitHub Desktop.
Save lvidal1/84d9d13d0dcbd0276fbf91600ba37990 to your computer and use it in GitHub Desktop.
Debounce on typing with Rxjs
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