Single<ResultType> result1 = Single.<ResultType>create(source -> {
source.onSuccess(method1(parameters));
}).subscribeOn(Schedulers.io());
Single<ReturnType> result2 = Single.<ResultType>create(source -> {
source.onSuccess(method2(parameters));
}).subscribeOn(Schedulers.io());
if (null != result1 && null != result2) {
--
You received this message because you are subscribed to the Google Groups "RxJava" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rxjava+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rxjava/c7b2871d-3b3e-4832-8b62-bae3c68acc24%40googlegroups.com.
Hi.First of all, I recommend reading the Getting started because the assumptions you listed are wrong. https://github.com/ReactiveX/RxJava#getting-started
Second, result1 and result2 should be never null at that point but neither method1 nor method2 executes until there is a subscribe() call to both.
Third, I suggest asking such questions on StackOverflow as not many of us are watching this group.
David Karr <davidmic...@gmail.com> ezt írta (időpont: 2020. máj. 11., H, 21:33):
--We're using an old version of rxjava, 2.1.10. I can't upgrade at this moment.I've been writing Java code for many years, but I'm a beginner to rxjava. Many of the services I supervise and work on use it, but I haven't had a chance to write much code using it. I first want to understand some of the patterns I see being used in our code.I see many examples of something like this:
Single<ResultType> result1 = Single.<ResultType>create(source -> {
source.onSuccess(method1(parameters));
}).subscribeOn(Schedulers.io());
Single<ReturnType> result2 = Single.<ResultType>create(source -> {
source.onSuccess(method2(parameters));
}).subscribeOn(Schedulers.io());
if (null != result1 && null != result2) {
The intent of this is that the execution of "method1" and "method2" run in parallel, and that the check for "null != result1 && null != result2" happens after both methods have finished executing. I'm thinking it's possible that neither of these intentions are being fulfilled here, but I need confirmation of that, and also how to achieve those goals properly.
You received this message because you are subscribed to the Google Groups "RxJava" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rxj...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rxjava/c7b2871d-3b3e-4832-8b62-bae3c68acc24%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to rxjava+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rxjava/97630b78-dacc-4851-8436-3292ba0d64fc%40googlegroups.com.
> Care to specify which assumptions I am making are wrong?"check for "null != result1 && null != result2" happens after both methods have finished executing [...] I'm thinking it's possible that neither of these intentions are being fulfilled here"It's not possible.
> As you can see, I have a subscribe call for both.I don't see it. The last line I see in the email isif (null != result1 && null != result2) { .subscribeOn != subscribe
> What I still want confirmation of is that "method1" and "method2" will execute essentially in parallelYes:result1.subscribe(value1 -> { });result2.subscribe(value2 -> { });Now both method1 and method2 will execute on the IO background thread in parallel, independent of each other.
To view this discussion on the web visit https://groups.google.com/d/msgid/rxjava/97630b78-dacc-4851-8436-3292ba0d64fc%40googlegroups.com.