-
-
Save tomas-langer/a61807a6fedeba9c84b49f7278e43bf8 to your computer and use it in GitHub Desktop.
Medium-Nima-Reactive-Parallel
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
// create a dummy stream from numbers 0 to count | |
Multi.range(0, count) | |
// for each number, call the task on a different thread | |
.flatMap(i -> Single.create(CompletableFuture.supplyAsync(() -> | |
client().get().request(String.class), EXECUTOR)) | |
// flat map from Single<Single<String>> to Single<String> | |
.flatMap(Function.identity())) | |
.collectList() | |
.map(it -> "Combined results: " + it) | |
.onError(res::send) | |
.forSingle(res::send); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment