These are chat archives for ReactiveX/RxJava

5th
Jun 2017
Rémon S.
@Coffee2CodeNL
Jun 05 2017 14:54
Hey people :D
I'm wondering, what's a proper way to implement a plugin system that can add observables to the chain programatically? say i've got a List<Observable>, how could i add those to the chain?
Rémon S.
@Coffee2CodeNL
Jun 05 2017 15:37
I'm guessing flatmap and a for loop?
Rémon S.
@Coffee2CodeNL
Jun 05 2017 16:23
Anyone?
Mark Elston
@melston
Jun 05 2017 17:26
@iSDP , I'm not sure what you are trying to do but have you tried the Concat or Merge operators?
Heikki Vesalainen
@hvesalai
Jun 05 2017 18:00
@iSDP you mean an Observable<Observable<T>> ?
then it would be a flatMap
Rémon S.
@Coffee2CodeNL
Jun 05 2017 18:39
@melston @hvesalai I'm trying to create a Plugin system, I've got an observable that emits an Update object, and depending on what the Update object contains, I want those plugins to be able to act on it
I'm building a Telegram Bot API Library based on RxJava2 and Retrofit
That observable that emits those Update objects is a long polling mechanism
I want end users to be able to hook their own plugins into the "chain"
The Update object gets passed on nonetheless
Heikki Vesalainen
@hvesalai
Jun 05 2017 18:42
so why wouldn't the plugins just subscribe to the same observable?
Rémon S.
@Coffee2CodeNL
Jun 05 2017 18:43
So that means the Update Observable would become a connectable?
I'm kinda still wrapping my head around this whole reactive business
Heikki Vesalainen
@hvesalai
Jun 05 2017 18:45
refcount
Rémon S.
@Coffee2CodeNL
Jun 05 2017 18:46
refcount?
Heikki Vesalainen
@hvesalai
Jun 05 2017 18:48
if you have a connectable and want to turn that into a normal observable
Rémon S.
@Coffee2CodeNL
Jun 05 2017 18:49
Ahh, but an Observable can only be subscribed to once, right? Connectables allow multiple subscribers as far as I understand it
Rémon S.
@Coffee2CodeNL
Jun 05 2017 18:54
Ah so there are all the docs o_k
O_o*
Heikki Vesalainen
@hvesalai
Jun 05 2017 19:04
:+1:
Rémon S.
@Coffee2CodeNL
Jun 05 2017 19:05
Thank you very much!
Can you extend the observable class and create an observable with that?
Heikki Vesalainen
@hvesalai
Jun 05 2017 19:12

I'm still wrapping my head around all this reactive stuff. I have to constantly test things out because I'm not sure how they work.

For example, if I do (and pardon my scala)

Flowable<Int> as = Flowable.range(1, 10).shared();
Flowable<Int> bs = as.map(a -> a + 1);
as.drop(1).zip(bs, (a,b) -> { assert a == b; a+b });

Then will the assert always succeed or can it fail?

Rémon S.
@Coffee2CodeNL
Jun 05 2017 19:16
What's the advantage of Flowables?
Heikki Vesalainen
@hvesalai
Jun 05 2017 19:17
they are org.reactivestreams.Publisher compatible
which is important for me because I need the compatibility
@iSDP and no, don't extend Observable.
Rémon S.
@Coffee2CodeNL
Jun 05 2017 19:31
Hmm..
Heikki Vesalainen
@hvesalai
Jun 05 2017 19:33
why would you?
Rémon S.
@Coffee2CodeNL
Jun 05 2017 20:24
So users don't have to deal with stuff like the method on line 59: https://hastebin.com/imoteluqaf.java @hvesalai
Heikki Vesalainen
@hvesalai
Jun 05 2017 20:34
But why would they have to. You implement the creation of the observer there and that's it.
Rémon S.
@Coffee2CodeNL
Jun 05 2017 20:36
I mean, that method I've got there, that's not recommended right?
Heikki Vesalainen
@hvesalai
Jun 05 2017 20:41
you mean create?
Derek Wickern
@dwickern
Jun 05 2017 21:27
API design question: I know my Observable's total size upfront, and I want to convey to the consumer. The problem is, I only know the total size after I connect and start streaming values. The total size might change between subscriptions. Is there some way to expose metadata inline with the stream?
Heikki Vesalainen
@hvesalai
Jun 05 2017 21:32
nothing comes to mind
Derek Wickern
@dwickern
Jun 05 2017 21:37
I could emit metadata as the first value but that seems like an awful api
Heikki Vesalainen
@hvesalai
Jun 05 2017 21:41
Yeah, doesn't sound nice. Even if you used something like Either
why does the subscriber need to know the size?
Derek Wickern
@dwickern
Jun 05 2017 21:45
for progress reporting and whatnot
Rémon S.
@Coffee2CodeNL
Jun 05 2017 23:37
@hvesalai no, that static method that returns an observable, I reckon that's not the recommended way to do it?
getUpdateObservable();