#java#reactor#flux#buffer#
缓冲
视频讲解: https://www.bilibili.com/video/av81107026/
FluxMonoTestCase.java
package com.example.reactor; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import java.util.List; @Slf4j public class FluxMonoTestCase extends BaseTestCase { @Test public void buffer(){ Flux<String> stringFlux = Flux.just("a","b","c","d","e","f","g"); stringFlux.subscribe(x -> System.out.print("->"+x)); System.out.println(); Flux<List<String>> listFlux = stringFlux.buffer(2); listFlux.subscribe(x -> System.out.print("->"+x)); } }
结果:
->a->b->c->d->e->f->g ->[a, b]->[c, d]->[e, f]->[g]
关注公众号,坚持每天3分钟视频学习
原文地址:https://www.cnblogs.com/JavaWeiBianCheng/p/12114811.html
时间: 2024-11-15 09:49:19