#java#reactor#comcatMap#

有序映射

视频讲解:https://www.bilibili.com/video/av79705356/

Reactor系列(八)concatMap有序映射

FluxMonoTestCase.java
package com.example.reactor;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;

import java.time.Duration;

@Slf4j
public class FluxMonoTestCase extends BaseTestCase {
    @Test
    public void concatMap() throws InterruptedException {
        Flux<String> stringFlux1 = Flux.just("a","b","c","d","e","f","g","h","i");
        Flux<Flux<String>> stringFlux2 = stringFlux1.window(2);
        stringFlux2.concatMap(flux1 ->flux1.map(word ->word.toUpperCase())
                .delayElements(Duration.ofMillis(200)))
                .subscribe(x -> System.out.print("->"+x));
        Thread.sleep(2000);
    }
}
BaseTestCase.java
package com.example.reactor;

import java.util.Arrays;
import java.util.List;

public class BaseTestCase {
    protected static final List<Employee> list = Arrays.asList(
            new Employee(1, "Alex", 1000),
            new Employee(2, "Michael", 2000),
            new Employee(3, "Jack", 1500),
            new Employee(4, "Owen", 1500),
            new Employee(5, "Denny", 2000));
}

结果:

->A->B->C->D->E->F->G->H->I

关注公众号,坚持每天3分钟视频学习

Reactor系列(八)concatMap有序映射

相关文章:

  • 2021-08-16
  • 2022-12-23
  • 2019-06-14
  • 2022-02-05
  • 2022-02-21
  • 2022-01-25
  • 2021-08-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2021-07-11
  • 2021-10-22
  • 2022-03-02
  • 2021-07-04
相关资源
相似解决方案