rx-java

How to pass variable parameters to Observer?

↘锁芯ラ 提交于 2019-12-24 00:48:48
问题 I have two Observers that are merged with a flatMap. The first observer returns a value that is used when the second is called. Observable<Integer> mergedObservers = firstAPI.getFirstInfo(userLat, userLong) .flatMap(resultFirstObservable -> { try { return secondApi.getSecondInfo(resultFirstObservable.body().string(), "3") .onErrorResumeNext(e -> { e.printStackTrace(); return secondApi.getSecondInfo("defaultValue", "3"); }); } catch (IOException e) { e.printStackTrace(); secondApi

Fatal signal 11 (SIGSEGV) when use RxJava and play services vision

时光毁灭记忆、已成空白 提交于 2019-12-24 00:39:42
问题 In my application I use the definition of the person position in the picture. After that, using RxJava I process the resulting image and output the result. After complete re-run that process. All working perfectly on devices such as samsung, huawei, meizu and other (with android version 5.0 and higher). But on xiaomi (no matter what version of android) I getting this error: A/libc: invalid address or address of corrupt block 0xabc932a8 passed to dlfree A/libc: Fatal signal 11 (SIGSEGV), code

When using Schedulers, System.out.println prints nothing in RxJava

喜夏-厌秋 提交于 2019-12-24 00:28:04
问题 I'm fiddling around with RxJava and Schedulers. I implemented a very simple stream with a scheduler: Observable.just(1, 2, 3) .doOnNext(v -> Thread.currentThread().getName()) .subscribeOn(Schedulers.newThread()) .subscribe(v -> System.out.println(v)); The example above prints nothing in the console. I noticed, that when I block the main thread at the end using i.e. Thread.sleep(), System.out.println prints proper values - 1 2 3: Observable.just(1, 2, 3) .doOnNext(v -> Thread.currentThread()

Repeat/Resubscribe to Observable with condition based on emitted item(s)

夙愿已清 提交于 2019-12-23 16:53:46
问题 I have enum -values that will be emitted by an Observable : public enum BleGattOperationState { SUCCESSFUL, ERROR, NOT_INITIATED } public Observable<BleGattOperationState> readRssi() { return Observable.<BleGattOperationState>create(subscriber -> { if (someCondition()) { subscriber.onNext(BleGattOperationState.SUCCESSFUL); } else { subscriber.onNext(BleGattOperationState.NOT_INITIATED); } }); } Is there a way to resubscribe or to repeat the observable, if the NOT_INITIATED value is emitted?

RxJava, Proguard and sun.misc.Unsafe

本小妞迷上赌 提交于 2019-12-23 15:49:20
问题 I have problems with RxJava (1.1.0) when using Proguard . I didn't change RxJava version nor its .pro file, but after updating OkHttp I couldn't compile using Proguard because I had warnings about sun.misc.Unsafe not being present. rxJava.pro -keep class rx.schedulers.Schedulers { public static <methods>; } -keep class rx.schedulers.ImmediateScheduler { public <methods>; } -keep class rx.schedulers.TestScheduler { public <methods>; } -keep class rx.schedulers.Schedulers { public static **

NetworkOnMainThreadException with retrofit-beta2 and rxjava

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 15:48:36
问题 I recently upgraded from retroft-beta1 and this was working. I have the following interface for the API: public interface Service { @POST("path") Observable<Object> service(); } And the following call: service.service() .observeOn(AndroidSchedulers.mainThread()) .subscribe(); And it throws a NetworkOnMainThreadException. But this was working in retrofit-beta1. 回答1: From retrofit-beta2, calls to Observable methods now behave synchronously. So subscribeOn must be used: service.service()

Converting RxJava to RxScala

感情迁移 提交于 2019-12-23 12:53:17
问题 Is there a way to use both RxJava and RxScala in one project? import rx.lang.scala.{Observable => ScalaObservable} import rx.{Observable => JavaObservable} We have a module written in Java that is using the JavaObservable ( RxJava ). And then we have a Scala module that is supposed to use the Java module but is written in Scala. Are there convenient methods to transform these into the other? 回答1: Yes, this is possible by using the conversion functions such as toJavaObservable ,

Reuse subscriber

此生再无相见时 提交于 2019-12-23 12:47:25
问题 In RxJava I have a Subscriber object wich I subscribe on a Observable . Later on (some time after onComplete() has been invoked) I create a new Observable and subscribe with the same Subscriber instance used before. However, that seems not work. Is a subscriber not reusable? Example: class Loader extends Subscriber<T> { public void load(){ Observable.just("Foo").subscribe(this); } public void onComplete(){ // update UI } } In my code I would like to instantiate a Loader once, and call load()

Why are Flowables not Observables

痞子三分冷 提交于 2019-12-23 12:28:55
问题 Why are Flowables not Observables; Observable interface is pretty much a subset of Flowable, their implementations are pretty much the same. Why don't they implement a common interface so we can directly cast Flowable as Observable? 回答1: A small regret about introducing backpressure in RxJava 0.x is that instead of having a separate base reactive class, the Observable itself was retrofitted. The main issue with backpressure is that many hot sources, such as UI events, can't be reasonably

RXJava - Split and Combine an Observable

十年热恋 提交于 2019-12-23 12:18:58
问题 I am new to RxJava and need some help/guidance on how to do the following: I need to get two values from an Observable a String a List<.ObjectA> I then need to apply two different filters() on this list and then finally combine all of them(String, FilteredListA, FilteredListB) into a single observable. Is there a single chained call I can use???(need example of groupBy maybe) Below is the sample code that is doing the same. MasterObject = String, List<.ObjectA> Observable<ReturnObject>