These are chat archives for ReactiveX/RxJava

12th
Dec 2016
Alex Reisberg
@a-reisberg
Dec 12 2016 21:08
Quick question: the rxjava 1.* has this .asObservable for subjects
rxjava 2.* doesn't have that anymore
Thanks!
so if I have a subject and I want to turn it to an observable, what's a good way to do it?
Serban Balamaci
@balamaci
Dec 12 2016 21:24
you can make it a Flowable which is basically an Observable with a backpressure strategy by doing
            .toFlowable(BackpressureStrategy.MISSING)
or whatever overflow strategy you prefer maybe .toFlowable(BackpressureStrategy.BUFFER)
Alex Reisberg
@a-reisberg
Dec 12 2016 21:28
Thanks!
I just found hide
can I use that too?
Serban Balamaci
@balamaci
Dec 12 2016 21:32
I don't know what hide does, I think it prevents rxjava to do some optimizations like operator fusion, so it should not relate to what you want to do.
Alex Reisberg
@a-reisberg
Dec 12 2016 21:32
I see. All I really want to do is to hide the publish aspect of my Subject
Serban Balamaci
@balamaci
Dec 12 2016 21:38
I don't understand, both Subject, Observable, Flowables are some kind of Publishers as they allow subscribing to them. I understand that Observables are kind of deprecated in rxjava2 in favor of Flowables which force you to think about backpressure upfront(you need to specify a backpressure strategy when you create them), so why would you need an Observable. Anyway looks like a Flowable can simply be turned into an Observable by doing flowable.toObservable
Alex Reisberg
@a-reisberg
Dec 12 2016 21:39
I guess I'm trying to move from Rx 1 and haven't fully understood exactly what the difference is
also my question was unclear. On a Subject you can do a onNext
(which is essentially publishing to other Observers)
and I wanted to hide the onNext
I didn't know that Observables are in the process of being deprecated?
Justin Tuchek
@jtuchek
Dec 12 2016 21:43
I highly doubt Observable is on any path to being deprecated. It’s just different from Flowable, where it wouldn’t make sense to discard events (such of cursor movements).
Serban Balamaci
@balamaci
Dec 12 2016 21:46
I'd say not deprecated, but not much different than Flowable as I do not see reasons where I'd want to use Observables instead of Flowables(which have the benefit that you are aware of backpressure and what the backpressure strategy is and you won't be surprised at runtime by a MissingBackpressuException)
Justin Tuchek
@jtuchek
Dec 12 2016 21:55
From reading the Observable source code from 2.x.x it seems to be utilizing an unbounded amount for input events - and from the docs of 2.0 it seems like you are going to hit an OOM instead.
Serban Balamaci
@balamaci
Dec 12 2016 22:01
I think so, then it would be equivalent to a Flowable if we'd do a .toFlowable(BackpressureStrategy.BUFFER)
which is also unbounded
but at least you know upfront you might expect an OOM
Justin Tuchek
@jtuchek
Dec 12 2016 22:05
The @BackPressureSupport(…) and @SchedulerSupport(…) annotations are really helpful when going through the code :thumbsup:
Serban Balamaci
@balamaci
Dec 12 2016 22:09
true