篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java RxTextView for Search Textbox相关的知识,希望对你有一定的参考价值。
public Observable<SearchResult> search(@NotNull EditText searchView) {
return RxTextView.textChanges(searchView) // In production, share this text view observable, don't create a new one each time
.map(CharSequence::toString)
.debounce(500, TimeUnit.MILLISECONDS) // Avoid getting spammed with key stroke changes
.filter(s -> s.length() > 1) // Only interested in queries of length greater than 1
.observeOn(workerScheduler) // Next set of operations will be network so switch to an IO Scheduler (or worker)
.switchMap(query -> searchService.query(query)) // Take the latest observable from upstream and unsubscribe from any previous subscriptions
.onErrorResumeNext(Observable.empty()); // <-- This will terminate upstream (ie. we will stop receiving text view changes after an error!)
}
以上是关于java RxTextView for Search Textbox的主要内容,如果未能解决你的问题,请参考以下文章