These are chat archives for ReactiveX/RxJava

18th
Dec 2017
Boris Maslakov
@bmaslakov
Dec 18 2017 11:54

Greetings, RxJava community. I was wondering if there's a cleaner alternative for such:

obj.method1()
  .flatMap { v -> obj.method2(v).map { v } };

i.e. we get a result of an operation, start another operation, wait for the second operation to complete and discard its result.

Option 2 is even more verbose:

create { subscriber ->
  obj.method1()
    .subscribe { v ->
      obj.method2(v)
        .subscribe {
          subscriber.onNext(v);
        }
    }
}

What do you think? Is option 1 is the best we could do?

David Karnok
@akarnokd
Dec 18 2017 12:24
Nesting subscribe calls like option 2 is definitely discouraged.