Reactor系列(十四)buffer緩衝

java#reactor#flux#buffer

緩衝java

視頻講解: https://www.bilibili.com/vide...

FluxMonoTestCase.javareact

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));
    }
}

結果:api

\->a->b->c->d->e->f->g \->\[a, b\]->\[c, d\]->\[e, f\]->\[g\]

關注公衆號,堅持天天3分鐘視頻學習
ide

相關文章
相關標籤/搜索