【问题标题】:Buffer with other publisher - Spring reactor与其他发布者缓冲 - Spring reactor
【发布时间】:2017-10-02 23:15:10
【问题描述】:

谁能举例说明 Flux.buffer(Publisher other) 的工作原理,我无法利用其他发布者将原始通量拆分为多个列表。

例如:

    List<String> strings = new ArrayList<>();
    strings.add("A");
    strings.add("B");
    Flux<String> stringFlux = Flux.fromIterable(strings).cache();


    for(int i = 0; i < 100; i++) {
        strings.add(""+i);
    }
    List<Integer> integers = new ArrayList<>(2);
        integers.add(1);
    integers.add(1);
    integers.add(1);

    stringFlux.buffer((a) -> {
        Flux.fromIterable(integers);
    }).subscribe(a -> {
        System.out.println(a);
    });

这仍然将原始列表打印为输出,而不是拆分它。

【问题讨论】:

    标签: spring project-reactor


    【解决方案1】:

    bufferuntil 带有谓词实际上是我想要的。

    【讨论】:

      猜你喜欢
      • 2019-08-25
      • 1970-01-01
      • 2015-01-06
      • 1970-01-01
      • 2019-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多