Adapt From-To Other Classes

We can convert from Reactor (Mono or Flux) to RxJava classes such as Observable or Flowable

This is because they're both implemented from Reactive Stream

Adapt between RxJava Flowable and Flux

static Flux<User> fromFlowableToFlux(Flowable<User> flowable) {  
  return Flux.from(flowable);  
}
static Flowable<User> fromFluxToFlowable(Flux<User> flux) {  
  return Flowable.fromPublisher(flux);  
}

Adapt between RxJava Observable and Flux

static Flux<User> fromObservableToFlux(Observable<User> observable) {  
  return Flux.from(observable.toFlowable(BackpressureStrategy.BUFFER));  
}
static Observable<User> fromFluxToObservable(Flux<User> flux) {  
  return Observable.fromPublisher(flux);  
}

For Observable, we need to first convert it to Flowable since Observable doesn't have BackPressure

Adapt between Single and Mono

static Mono<User> fromSingleToMono(Single<User> single) {  
  return Mono.from(single.toFlowable());  
}
static Single<User> fromMonoToSingle(Mono<User> mono) {  
  return Single.fromPublisher(mono);  
}

Adapt between CompletableFuture and Mono

static CompletableFuture<User> fromMonoToCompletableFuture(Mono<User> mono) {  
  return mono.toFuture();  
}
static Mono<User> fromCompletableFutureToMono(CompletableFuture<User> future) {  
  return Mono.fromFuture(future);  
}

[!important]
Only Mono can convert to CompletableFuture, not Flux