java RxTextView for Search Textbox

Posted

tags:

篇首语:本文由小常识网(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的主要内容,如果未能解决你的问题,请参考以下文章

RxTextView实现对多个EditText/TextView进行监听(其他控件自行设定逻辑)

使用最新的 com.jakewharton.rxbinding3:rxbinding:3.0.0-alpha2 库时未找到 RxTextView 和其他小部件

翻转游戏

LeetCode 236. Lowest Common Ancestor of a Binary Tree; 235. Lowest Common Ancestor of a Binary Searc

Alamofire 不下载 PDF

解析嵌套完成处理程序