Reactor系列(十四)buffer缓冲

 约 3 分钟

java#reactor#flux#buffer

缓冲

视频讲解: https://www.bilibili.com/vide...

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分钟视频学习

阅读 434

推荐阅读
目录