rx-java

Rx - How to unsubscribe automatically after receiving onNext()?

旧巷老猫 提交于 2021-02-07 05:08:38
问题 How to unsubscribe automatically after receiving onNext() ? For now I use this code: rxObservable .compose(bindToLifecycle()) // unsubscribe automatically in onPause() if method was called in onResume() .subscribe(new Subscriber<Object>() { ... @Override public void onNext(Object o) { unsubscribe(); } }); 回答1: I you want to "unsubscribe" just after the first event, the operator take is a way to go. rxObservable.compose(bindToLifecycle()) .take(1) .subscribe(); 回答2: I think this is what you

Rx - How to unsubscribe automatically after receiving onNext()?

对着背影说爱祢 提交于 2021-02-07 05:05:12
问题 How to unsubscribe automatically after receiving onNext() ? For now I use this code: rxObservable .compose(bindToLifecycle()) // unsubscribe automatically in onPause() if method was called in onResume() .subscribe(new Subscriber<Object>() { ... @Override public void onNext(Object o) { unsubscribe(); } }); 回答1: I you want to "unsubscribe" just after the first event, the operator take is a way to go. rxObservable.compose(bindToLifecycle()) .take(1) .subscribe(); 回答2: I think this is what you

Failed resolution of: Lcom/google/devtools/build/android/desugar/runtime/ThrowableExtension;

ぃ、小莉子 提交于 2021-02-06 15:29:39
问题 I'm using RxJava with Retrofit on the newest preview of AndroidStudio. My project has java 1.8 suport enabled like this: compileOptions { targetCompatibility 1.8 sourceCompatibility 1.8 } But when the code is compiled and run I'm getting this error, as soon as the request is made, even if I have the onError handler: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/devtools/build/android/desugar/runtime/ThrowableExtension; at io.reactivex.plugins.RxJavaPlugins.onError

Failed resolution of: Lcom/google/devtools/build/android/desugar/runtime/ThrowableExtension;

自古美人都是妖i 提交于 2021-02-06 15:26:13
问题 I'm using RxJava with Retrofit on the newest preview of AndroidStudio. My project has java 1.8 suport enabled like this: compileOptions { targetCompatibility 1.8 sourceCompatibility 1.8 } But when the code is compiled and run I'm getting this error, as soon as the request is made, even if I have the onError handler: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/devtools/build/android/desugar/runtime/ThrowableExtension; at io.reactivex.plugins.RxJavaPlugins.onError

RxJava: Error occurred when trying to propagate error to Observer.onError

眉间皱痕 提交于 2021-02-06 14:20:38
问题 I am getting a IllegalStateException error in the Rx Library and don't know exactly where the root of the issue is, whether it is with RxJava or something I may be doing incorrectly. The fatal crash occurs when certificate pinning (occurs on all server requests) but seems to point to a session timeout or logout and back in. Repro steps (occures about 25% of the time) are as follows: login, open list item - scroll all the way end - logout - logback in - open app - close app -> Crash! Anyone

Right way of using RxJava + Retrofit 2

核能气质少年 提交于 2021-02-06 13:52:08
问题 I have such JSON: { "success":true, "data":[ { "id":"29", "name":"\u0420\u0435\u0441\u0442\u043e\u0440\u0430\u0446\u0456\u044f \u0411\u0430\u0447\u0435\u0432\u0441\u044c\u043a\u0438\u0445 \/ Baczewski Restaurant", "street":"\u0432\u0443\u043b. \u0428\u0435\u0432\u0441\u044c\u043a\u0430, 8", "latitude":"49.842292845502", "longitude":"24.029848249565", "image":"https:\/\/i.onthe.io\/j9aocq72r2lfsmoh9.r500x500.01ff9fff.jpg" }, ... ] } According to it have to Classes (pojo) created with schema to

Right way of using RxJava + Retrofit 2

≡放荡痞女 提交于 2021-02-06 13:48:59
问题 I have such JSON: { "success":true, "data":[ { "id":"29", "name":"\u0420\u0435\u0441\u0442\u043e\u0440\u0430\u0446\u0456\u044f \u0411\u0430\u0447\u0435\u0432\u0441\u044c\u043a\u0438\u0445 \/ Baczewski Restaurant", "street":"\u0432\u0443\u043b. \u0428\u0435\u0432\u0441\u044c\u043a\u0430, 8", "latitude":"49.842292845502", "longitude":"24.029848249565", "image":"https:\/\/i.onthe.io\/j9aocq72r2lfsmoh9.r500x500.01ff9fff.jpg" }, ... ] } According to it have to Classes (pojo) created with schema to

Right way of using RxJava + Retrofit 2

非 Y 不嫁゛ 提交于 2021-02-06 13:47:29
问题 I have such JSON: { "success":true, "data":[ { "id":"29", "name":"\u0420\u0435\u0441\u0442\u043e\u0440\u0430\u0446\u0456\u044f \u0411\u0430\u0447\u0435\u0432\u0441\u044c\u043a\u0438\u0445 \/ Baczewski Restaurant", "street":"\u0432\u0443\u043b. \u0428\u0435\u0432\u0441\u044c\u043a\u0430, 8", "latitude":"49.842292845502", "longitude":"24.029848249565", "image":"https:\/\/i.onthe.io\/j9aocq72r2lfsmoh9.r500x500.01ff9fff.jpg" }, ... ] } According to it have to Classes (pojo) created with schema to

What is the difference between Schedulers.io() and Schedulers.computation()

痴心易碎 提交于 2021-02-06 09:48:18
问题 I use Observables in couchbase. What is the difference between Schedulers.io() and Schedulers.computation() ? 回答1: From the documentation of rx: Schedulers.computation( ) - meant for computational work such as event-loops and callback processing; do not use this scheduler for I/O (use Schedulers.io( ) instead); the number of threads, by default, is equal to the number of processors Schedulers.io( ) - meant for I/O-bound work such as asynchronous performance of blocking I/O, this scheduler is

What is the difference between Schedulers.io() and Schedulers.computation()

不羁的心 提交于 2021-02-06 09:46:35
问题 I use Observables in couchbase. What is the difference between Schedulers.io() and Schedulers.computation() ? 回答1: From the documentation of rx: Schedulers.computation( ) - meant for computational work such as event-loops and callback processing; do not use this scheduler for I/O (use Schedulers.io( ) instead); the number of threads, by default, is equal to the number of processors Schedulers.io( ) - meant for I/O-bound work such as asynchronous performance of blocking I/O, this scheduler is