These are chat archives for ReactiveX/RxJava

2nd
Jul 2017
Exerosis
@Exerosis
Jul 02 2017 00:36
Is there some type of Observable that has two types of data? I know a pair works fine, but I'm considering using this lib in an API I'm working on, Observables would be useful, but I would feel obligated to replace existing methods like onAdd(Consumer<Type> listener) with observable equivalents. In which case, I would end up doing a ton of pairing and then unpairing, which isn't something I really want to do(performance and more work for API user).
Mark Raynsford
@io7m
Jul 02 2017 09:00
@Dorus it's a possibility, but I'm exploring all options (that was basically the response I expected, I realize subjects aren't popular)
David Karnok
@akarnokd
Jul 02 2017 09:23
@io7m Use toSerialized(): it protects the Subject from reentrance and concurrent usage problems.
Mark Raynsford
@io7m
Jul 02 2017 09:24
@akarnokd Ah, interesting. Thank you! I'll give it a shot
I sort of blanked when I saw a "serialized" subject type as I thought it referred to Serializable... :smile:
David Karnok
@akarnokd
Jul 02 2017 09:25
@Exerosis No, that requires a complete new library.
Mark Raynsford
@io7m
Jul 02 2017 10:38
@akarnokd Playing around a bit with serialized subjects... It does indeed project the subject from issues of re-entrancy and the like, but the problem is then that it turns a stack overflow exception into non-termination instead. Is there perhaps some way to make the recursion bounded? With the original stack overflow, the recursion is only bounded by the maximum stack size. I'm curious if there's some way to set a very low bound (say eight recursive calls before an unchecked exception of some type is raised)
David Karnok
@akarnokd
Jul 02 2017 11:46
Don't use Subjects and redesign your flows so that you don't need to trigger "yourself".
Mark Raynsford
@io7m
Jul 02 2017 11:51
right
Exerosis
@Exerosis
Jul 02 2017 18:24
@akarnokd Ah I see, although I actually did realize I can emulate the effect by creating a custom consumer. The issue is, unless I make a custom observable(have yet to check if this is even possible) I will still need to explicitly type my lambdas.