'RxJava - Helper method to return previous result after executing Callable

I am using the Single RxJava object and I want to run a void method in the critical path of the async workflow but return the previous result.

For example, I have something like:

Single<Integer> method() {
  Single<Integer> value = Single.just(10);
  return value.<RxJava Method>(Consumer<Integer> or Runnable<Integer>);
}

method().blockingGet();

returns

> 10

The stuff I do in Consumer<Integer> or Runnable<Integer>, I want to make sure happens before I return the value 10. Is there a built in method in Single for this?

ie: I am just wondering if there is a cleaner way to portray:

Single<Integer> method() {
  Single<Integer> value = Single.just(10);
  return value.map(result -> {
    // call void method
    return result;
  });
}

method().blockingGet();


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source