class CompletableFutureToObservable {

    public static <T>Observable<T> fromCompletableFuture(CompletableFuture<T> cf) {
        return Observable.create(subscriber -> cf.thenAccept(value -> { subscriber.onNext(value); subscriber.onComplete(); })
                .exceptionally(ex -> { subscriber.onError(ex); return null;} ));
    }

}