zoukankan      html  css  js  c++  java
  • Reactor系列(七)flatMap映射

    #java##reactor##flatMap#

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

    FluxMonoTestCase.java
    package com.example.reactor;
    
    import lombok.extern.slf4j.Slf4j;
    import org.junit.jupiter.api.Test;
    import reactor.core.publisher.Flux;
    
    @Slf4j
    public class FluxMonoTestCase extends BaseTestCase {
        @Test
        public void flatMap(){
            Flux<String> stringFlux1 = Flux.just("a","b","c","d","e","f","g","h","i");
            //嵌套Flux
            Flux<Flux<String>> stringFlux2 = stringFlux1.window(2);
            stringFlux2.flatMap(flux1 ->flux1.map(word ->word.toUpperCase()))
                    .subscribe(System.out::println);
            //从嵌套Flux还原字符串Flux
            Flux<String> stringFlux3 = stringFlux2.flatMap(flux1 ->flux1);
            // stringFlux1 等于 stringFlux3
            stringFlux3.subscribe(System.out::println);
        }
    }
    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));
    }

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

  • 相关阅读:
    数组
    Fiddler抓手机APP包
    APP测试注意点-安装卸载与运行
    【转】查看iOS崩溃日志
    Monkey 命令
    python del 函数
    探索性测试方法
    解决5037端口占用的方法
    App测试Android的闪退总结
    Jenkins邮件配置
  • 原文地址:https://www.cnblogs.com/JavaWeiBianCheng/p/12053465.html
Copyright © 2011-2022 走看看