ReactiveJava

Wed, Dec 1, 2021 閱讀時間 1 分鐘

init

Flux<String> seq1 = Flux.just("Bill", "Is", "Good");
Flux<String> seq2 = Flux.fromIterable(Arrays.asList("Bill", "Is", "Good"));
Flux<Integer> intFrom5To6 = Flux.range(5, 2); 
Mono<String> mono = Mono.just("Bill");
Mono<String> mono1 = Mono.empty(); 
Mono<String> mono2 = Mono.justOrEmpty("Robert"); 

onError, onComplete, onNext

Flux<Integer> intList = Flux.range(1, 10);
intList.subscribe(
    n -> System.out.println(n),
    error -> System.err.println("Error " + error),
    () -> System.out.println("Done"));

Map, FlatMap

map flatMap
轉換一個來源對應一個輸出 轉換一個來源對應一個Flux(N個)
單純的處理轉換 subscribe每一個Flux
synchronous Async

mergeWith

Zip