These are chat archives for ReactiveX/RxJava

Sep 2018
Sergey Serdyuk
Sep 13 2018 08:11
Hi everyone, I have a question:
.flatMap(r -> serviceReturnObservable2.getSomeData(r.getValue()))
.flatMap( here I want to work with ServiceReturnObservable1.getData() and serviceReturnObservable2.getSomeData(r.getValue()))
Pulkit Kumar
Sep 13 2018 09:22
@neee serviceReturnObservable2.getSomeData(r.getValue()) should emit an object which has everything you need to chain it further. Since it is already accepting value emitted by ServiceReturnObservable1, you should be able to add those values to the object emitted by ServiceReturnObservable2 .
Dan O'Reilly
Sep 13 2018 14:19
@neee i usually .map to a tuple type inside of the first flatMap call, or nest the second flatMap call inside the first
i have a bunch of helpers for automatically "chaining" the second emitted value into a tuple with the previous emitted value, and then unpacking the tuple in the next call
So you'd end up with
    .flatMap(chainObs(r -> serviceReturnObservable2.getSomeData(r.getValue())))
    .flatMap(unpack((r1, r2) -> ...))
Ignacio Baca Moreno-Torres
Sep 13 2018 14:32
you know this sorcery works since java8 and can be saved in var since java10 :scream:
        .flatMap(n -> Observable.just("a","b","c")
                .map(s -> new Object() { Integer num = n; String str = s; }))
        .subscribe(obj -> System.out.println(obj.num + ":" + obj.str));
Ricky Limka
Sep 13 2018 15:49

Hey everyone, today I encountered a strange behavior with Observable.create:

private ObservableEmitter<Action> extEmitter;

    public Test() {
        Observable<Action> actions = Observable.create(emitter -> {
            extEmitter = emitter;


        Observable<Action> reverts = actions.filter(Action.REVERT::equals);
        Observable<Action> tests = actions.filter(Action.TEST::equals);

        Observable.merge(tests, reverts).subscribe(System.out::println);


Does anyone know why using extEmitter (emitter outside of lambda) emits different results than emitter inside lambda?

↑ what is the common practice for exporting emitter outside for pushing custom values from other java classes?
Ricky Limka
Sep 13 2018 16:02
I should have used Rx.Subject instead?