Closed peng0398 closed 8 years ago
This is the Rx contract. If you need a stream to continue then ensure it doesn't error or re-subscribe upstream on each error.
On Tue, Jul 26, 2016, 2:37 AM Bob.Peng notifications@github.com wrote:
RxTextView.textChanges(et_keyword) .subscribeOn(AndroidSchedulers.mainThread()) .debounce(600, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread()) .filter(new Func1() { @Override https://github.com/Override public Boolean call(CharSequence charSequence) { tv_result.setText(""); return charSequence.length() > 0; } }) .observeOn(Schedulers.io()) .switchMap(new Func1>() { @Override https://github.com/Override public Observable call(CharSequence charSequence) { return service.searchProdcut("utf-8", charSequence.toString()); } }) .map(new Func1>>() { @Override https://github.com/Override public ArrayList> call(Data data) { return data.result; } }) .flatMap(new Func1>, Observable>>() { @Override https://github.com/Override public Observable> call(ArrayList> arrayLists) { return Observable.from(arrayLists); } }) .filter(new Func1, Boolean>() { @Override https://github.com/Override public Boolean call(ArrayList strings) { return strings.size() >= 2; } }) .map(new Func1, String>() { @Override https://github.com/Override public String call(ArrayList strings) { return "[name:" + strings.get(0) + ", ID:" + strings.get(1) + "]\n"; } }) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Action1() { @Override https://github.com/Override public void call(String charSequence) { showpop(charSequence); } }, new Action1() { @Override https://github.com/Override public void call(Throwable throwable) { // Handle Error throwable.printStackTrace(); } });
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JakeWharton/RxBinding/issues/272, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEZBkqfh6w_UThUkWsoIaSQTO3nyLks5qZatDgaJpZM4JU1Ik .
Just like the code below , using RxTextView.textChanges for a search function ,once the text changed, I do a lot of other works ,the progress may produce error ,when onError is run , the textChanges will not emiit text changes .