Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

Add conversion between RxJava Completable and ListenableFuture<Void> #90

Open
TheKeveloper opened this issue Feb 3, 2023 · 0 comments

Comments

@TheKeveloper
Copy link

Currently, we can only convert from Single<T> to ListenableFuture<T>. We can't convert from RxJava Completable to Single<Void> because the only valid type for a Void is null, and RxJava explicitly prevents having a Single with a null value.

There is a way to workaround this by just using a dummy object as the value of the Single,

Futures.transform(
  FutureConverter.fromSingle(
    completable.toSingleDefault(new Object())), 
    _ignored -> null, 
    MoreExecutors.directExecutor())

But the above is pretty messy. It seems like it should be pretty straightforward to convert from Completable to ListenableFuture<Void> (or CompletableFuture<Void> for that matter).

Happy to take this on myself if this sounds reasonable!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant