modules/jooby-rxjava/src/main/java/org/jooby/rx/Rx.java
@SuppressWarnings("unchecked")
  public static Route.Mapper<Object> rx(final Function<Observable, Observable> observable,
    final Function<Single, Single> single, final Function<Completable, Completable> completable) {
    requireNonNull(observable, "Observable's adapter is required.");
    requireNonNull(single, "Single's adapter is required.");
    requireNonNull(completable, "Completable's adapter is required.");

    return Route.Mapper.create("rx", v -> {
      if (v instanceof Observable) {
        return new Deferred(
          deferred -> observable.apply((Observable) v).subscribe(new DeferredSubscriber(deferred)));
      } else if (v instanceof Single) {
        return new Deferred(
          deferred -> single.apply((Single) v).subscribe(new DeferredSubscriber(deferred)));
      } else if (v instanceof Completable) {
        return new Deferred(deferred -> completable.apply((Completable) v)
          .subscribe(new DeferredSubscriber(deferred)));
      }
      return v;
    });
  }
@SuppressWarnings("unchecked")
  public static Route.Mapper<Object> rx(final Function<Observable, Observable> observable,
    final Function<Single, Single> single, final Function<Completable, Completable> completable) {
    requireNonNull(observable, "Observable's adapter is required.");
    requireNonNull(single, "Single's adapter is required.");
    requireNonNull(completable, "Completable's adapter is required.");

    return Route.Mapper.create("rx", v -> {
      if (v instanceof Observable) {
        return new Deferred(
          deferred -> observable.apply((Observable) v).subscribe(new DeferredSubscriber(deferred)));
      } else if (v instanceof Single) {
        return new Deferred(
          deferred -> single.apply((Single) v).subscribe(new DeferredSubscriber(deferred)));
      } else if (v instanceof Completable) {
        return new Deferred(deferred -> completable.apply((Completable) v)
          .subscribe(new DeferredSubscriber(deferred)));
      }
      return v;
    });
  }
Map a rx object like {@link Observable}, {@link Single} or {@link Completable} into a
{@link Deferred} object.

<pre>{@code
...
import org.jooby.rx.Rx;
...

{
use(new Rx());

with(() -> {
get("/1", req -> Observable...);

get("/2", req -> Observable...);

....

get("/N", req -> Observable...);

}).map(Rx.rx(
observable -> observable.observeOn(Scheduler.io()),
single -> single.observeOn(Scheduler.io()),
completable -> completable.observeOn(Scheduler.io())));
}
}</pre>

@param observable Observable adapter.
@param single Single adapter.
@param completable Completable adapter.
@return A new mapper.