zoukankan      html  css  js  c++  java
  • Reactor系列(十三)zipWith压缩

    #java#reactor#flux#zip#

    压缩

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

    FluxMonoTestCase.java
    package com.example.reactor;
    
    import lombok.extern.slf4j.Slf4j;
    import org.junit.jupiter.api.Test;
    import reactor.core.publisher.Flux;
    import reactor.util.function.Tuple3;
    
    @Slf4j
    public class FluxMonoTestCase extends BaseTestCase {
        @Test
        public void zip(){
            Flux<String> stringFlux1 = Flux.just("a","b","c","d","e");
            Flux<String> stringFlux2 = Flux.just("f","g","h","i");
            Flux<String> stringFlux3 = Flux.just("1","2","3","4");
            //方法一zipWith
            stringFlux1.zipWith(stringFlux2).subscribe(x -> log.info("->{}",x));
            System.out.println();
            //方法二zip
            Flux<Tuple3<String,String,String>> tuple2Flux = Flux.zip(stringFlux1,stringFlux2,stringFlux3);
            tuple2Flux.subscribe(x -> log.info("->{}",x));
        }
    }

    结果:

    11:28:47.027 [main] INFO com.example.reactor.FluxMonoTestCase - ->[a,f]
    11:28:47.028 [main] INFO com.example.reactor.FluxMonoTestCase - ->[b,g]
    11:28:47.028 [main] INFO com.example.reactor.FluxMonoTestCase - ->[c,h]
    11:28:47.028 [main] INFO com.example.reactor.FluxMonoTestCase - ->[d,i]
    
    11:28:47.029 [main] INFO com.example.reactor.FluxMonoTestCase - ->[a,f,1]
    11:28:47.029 [main] INFO com.example.reactor.FluxMonoTestCase - ->[b,g,2]
    11:28:47.029 [main] INFO com.example.reactor.FluxMonoTestCase - ->[c,h,3]
    11:28:47.029 [main] INFO com.example.reactor.FluxMonoTestCase - ->[d,i,4]
  • 相关阅读:
    返回顶部按钮效果实现
    WebAPI Angularjs 上传文件
    C# 单元测试
    C# 如何获取Url的host以及是否是http
    Dapper批量操作实体
    易优CMS:type的基础用法
    易优CMS:arcview基础用法
    易优CMS:channel的基础用法
    易优CMS:arclist 文档列表
    c语言必背代码
  • 原文地址:https://www.cnblogs.com/JavaWeiBianCheng/p/12101158.html
Copyright © 2011-2022 走看看