Created
February 8, 2017 07:56
-
-
Save asbadve/b3445231a5a46bfb5bb2e3ed8b29ef29 to your computer and use it in GitHub Desktop.
Stackover flow question
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
moviesAPI.searchQuery(newQuery) | |
.subscribeOn(Schedulers.newThread()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.debounce(new Func1<Search, Observable<Search>>() { | |
@Override | |
public Observable<Search> call(Search search) { | |
if (search.getSearchResults().size() == 0) { | |
return Observable.empty(); | |
} else { | |
return Observable.<Search>empty().delay(5, TimeUnit.SECONDS); | |
} | |
} | |
}) | |
.subscribe(new Subscriber<Search>() { | |
@Override | |
public void onCompleted() { | |
Log.d(TAG, "onCompleted() called"); | |
} | |
@Override | |
public void onError(Throwable e) { | |
floatingSearchView.hideProgress(); | |
Log.d(TAG, "onError() called with: e = [" + e + "]"); | |
} | |
@Override | |
public void onNext(Search search) { | |
floatingSearchView.hideProgress(); | |
floatingSearchView.swapSuggestions(search.getSearchResults()); | |
Log.d(TAG, "onNext() called with: search = [" + search + "]"); | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment