Created
May 7, 2022 10:27
-
-
Save chukonu/bfce69e532f6f119a9cf7e7b8939a1cb to your computer and use it in GitHub Desktop.
Flux.handle example
This file contains hidden or 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
import reactor.core.publisher.Flux; | |
import java.time.Duration; | |
import java.util.concurrent.CompletableFuture; | |
import java.util.concurrent.ExecutionException; | |
public class FluxHandleExample { | |
public static void main(String[] args) throws InterruptedException, ExecutionException { | |
CompletableFuture<Boolean> completableFuture = new CompletableFuture<>(); | |
Flux.just(0, 1, 2, 3) | |
.log("ONE") | |
.<Integer>handle((integer, synchronousSink) -> synchronousSink.next(integer * 10)) | |
.delayElements(Duration.ofSeconds(3)) | |
.log("TWO") | |
.doOnComplete(() -> completableFuture.complete(true)) | |
.subscribe(); | |
completableFuture.get(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment