Skip to content

Consuming Arrays from CompletableFutures with Uni / Multi #800

Answered by cescoffier
mikeymop asked this question in Q&A
Discussion options

You must be logged in to vote

If I understood correctly, you have something like:

CompletableFuture<List<Bucket>> retrieveBucketsUsingS3AsyncApi();

To obtain a Uni<List<Bucket>>, just use:

Uni<List<Bucket>> uni = Uni.createFrom().completionStage(() -> retrieveBucketsUsingS3AsyncApi());

If you need a Multi<Bucket>, use:

Multi<Bucket>> uni = Multi.createFrom().uni(() -> Uni.createFrom().completionStage(() -> retrieveBucketsUsingS3AsyncApi()))
   .map(list -> Multi.createFrom().items(list));

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cescoffier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants