Skip to content

Instantly share code, notes, and snippets.

@lvidal1
Created July 3, 2017 05:54
Show Gist options
  • Save lvidal1/42bc3e735ad40a16091ac381683e821f to your computer and use it in GitHub Desktop.
Save lvidal1/42bc3e735ad40a16091ac381683e821f to your computer and use it in GitHub Desktop.
Debounce on typing with Rxjs (pluck operator)
var input = document.querySelector('input');
var observable = Rx.Observable.fromEvent(input,'input');
observable
.pluck('target','value') // nested attributes from event
.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