These are chat archives for ReactiveX/RxJava
RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.
How to properly perform action after the subscription? doOnSubscribe doesn't fit the needs
PublishProcessor<Integer> processor = PublishProcessor.create(); processor .doOnSubscribe(subscription -> processor.onNext(1)) .subscribe(System.out::println); processor.onNext(2);
As a workaround i use this approach
processor .mergeWith(Completable.fromAction(() -> processor.onNext(1)).toFlowable()) .subscribe(System.out::println);
doOnSubscribeis not good in this case because the processor's
onNextdoesn't see the subscriber at that moment.
@akarnokd I have 2 event bus like processors. One is for requests second is for results. There may be multiple request handlers which will post a results to the result processor. This may be either synchronously or asynchronously. I want to make a request and wait for the result in the same flowable
PublishProcessor<Integer> requestBus = PublishProcessor.create(); PublishProcessor<Pair<Integer, Integer>> resultBus = PublishProcessor.create(); requestBus.filter(value -> value == 1) .map(value -> Pair.create(value, 10)) .subscribe(resultBus); Integer request = 1; Flowable<Integer> resultFlowable = resultBus .filter(requestResultPair -> requestResultPair.first == request) .doOnSubscribe(__ -> requestBus.onNext(request));