Skip to content

Instantly share code, notes, and snippets.

@ragdroid
Created August 21, 2016 18:01
Show Gist options
  • Save ragdroid/869be4afc868d38f1001a107aef4cc57 to your computer and use it in GitHub Desktop.
Save ragdroid/869be4afc868d38f1001a107aef4cc57 to your computer and use it in GitHub Desktop.
AutoSearch - debounce the search terms Droidcon 2016
//AutoSearch using debounce spell
public Observable<SearchRequest> autoSearch() {
return getSearchtermObservable()
.debounce(500, TimeUnit.MILLISECONDS)
.flatMap(new Func1<String, Observable<SearchRequest>>() {
@Override
public Observable<SearchRequest> call(String term) {
return Observable.just(new SearchRequest(term));
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment