Last active
May 11, 2016 16:20
-
-
Save gszeliga/73a0c5c120bbfa70ad3931d5cc431317 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T> CompletableFuture<Stream<T>> sequence(Stream<CompletableFuture<T>> source) { | |
return source | |
.reduce(completedFuture(Stream.empty()), | |
(fl, fo) -> fl.thenCombine(fo, (s, o) -> concat(s, Stream.of(o))), | |
(fa, fb) -> fa.thenCombine(fb, Stream::concat)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment