目录
buffer
buffer接口文档
<B> Flowable<List<T>> |
buffer(Callable<? extends Publisher<B>> boundaryIndicatorSupplier) Returns a Flowable that emits buffers of items it collects from the source Publisher. 返回一个Flowable,它发出从源Publisher收集的项目的缓冲区。 |
<B,U extends Collection<? super T>> |
buffer(Callable<? extends Publisher<B>> boundaryIndicatorSupplier,Callable<U> bufferSupplier) Returns a Flowable that emits buffers of items it collects from the source Publisher. 返回一个Flowable,它发出从源Publisher收集的项目的缓冲区。 |
<TOpening,TClosing> |
buffer(Flowable<? extends TOpening> openingIndicator, Function<? super TOpening,? extendsPublisher<? extends TClosing>> closingIndicator) Returns a Flowable that emits buffers of items it collects from the source Publisher. 返回一个Flowable,它发出从源Publisher收集的项目的缓冲区。 |
<TOpening,TClosing,U extends Collection<? super T>> |
buffer(Flowable<? extends TOpening> openingIndicator, Function<? super TOpening,? extendsPublisher<? extends TClosing>> closingIndicator, Callable<U> bufferSupplier) Returns a Flowable that emits buffers of items it collects from the source Publisher. 返回一个Flowable,它发出从源Publisher收集的项目的缓冲区。 |
Flowable<List<T>> |
buffer(int count) Returns a Flowable that emits buffers of items it collects from the source Publisher. 返回一个Flowable,它发出从源Publisher收集的项目的缓冲区。 |
<U extends Collection<? super T>> |
buffer(int count, Callable<U> bufferSupplier) Returns a Flowable that emits buffers of items it collects from the source Publisher. 返回一个Flowable,它发出从源Publisher收集的项目的缓冲区。 |
Flowable<List<T>> |
buffer(int count, int skip) Returns a Flowable that emits buffers of items it collects from the source Publisher. 返回一个Flowable,它发出从源Publisher收集的项目的缓冲区。 |
<U extends Collection<? super T>> |
buffer(int count, int skip, Callable<U> bufferSupplier) Returns a Flowable that emits buffers of items it collects from the source Publisher. 返回一个Flowable,它发出从源Publisher收集的项目的缓冲区。 |
Flowable<List<T>> |
buffer(long timespan, long timeskip, TimeUnit unit) Returns a Flowable that emits buffers of items it collects from the source Publisher. 返回一个Flowable,它发出从源Publisher收集的项目的缓冲区。 |
Flowable<List<T>> |
buffer(long timespan, long timeskip, TimeUnit unit, Scheduler scheduler) Returns a Flowable that emits buffers of items it collects from the source Publisher. 返回一个Flowable,它发出从源Publisher收集的项目的缓冲区。 |
<U extends Collection<? super T>> |
buffer(long timespan, long timeskip, TimeUnit unit, Scheduler scheduler,Callable<U> bufferSupplier) Returns a Flowable that emits buffers of items it collects from the source Publisher. 返回一个Flowable,它发出从源Publisher收集的项目的缓冲区。 |
Flowable<List<T>> |
buffer(long timespan, TimeUnit unit) Returns a Flowable that emits buffers of items it collects from the source Publisher. 返回一个Flowable,它发出从源Publisher收集的项目的缓冲区。 |
Flowable<List<T>> |
buffer(long timespan, TimeUnit unit, int count) Returns a Flowable that emits buffers of items it collects from the source Publisher. 返回一个Flowable,它发出从源Publisher收集的项目的缓冲区。 |
Flowable<List<T>> |
buffer(long timespan, TimeUnit unit, Scheduler scheduler) Returns a Flowable that emits buffers of items it collects from the source Publisher. 返回一个Flowable,它发出从源Publisher收集的项目的缓冲区。 |
Flowable<List<T>> |
buffer(long timespan, TimeUnit unit, Scheduler scheduler, int count) Returns a Flowable that emits buffers of items it collects from the source Publisher. 返回一个Flowable,它发出从源Publisher收集的项目的缓冲区。 |
<U extends Collection<? super T>> |
buffer(long timespan, TimeUnit unit, Scheduler scheduler, int count,Callable<U> bufferSupplier, boolean restartTimerOnMaxSize) Returns a Flowable that emits buffers of items it collects from the source Publisher. 返回一个Flowable,它发出从源Publisher收集的项目的缓冲区。 |
<B> Flowable<List<T>> |
buffer(Publisher<B> boundaryIndicator) Returns a Flowable that emits non-overlapping buffered items from the source Publisher each time the specified boundary Publisher emits an item. 返回一个Flowable,每次指定的边界Publisher发出项目时,它都会从源Publisher发出非重叠的缓冲项。 |
<B,U extends Collection<? super T>> |
buffer(Publisher<B> boundaryIndicator, Callable<U> bufferSupplier) Returns a Flowable that emits non-overlapping buffered items from the source Publisher each time the specified boundary Publisher emits an item. 返回一个Flowable,每次指定的边界Publisher发出项目时,它都会从源Publisher发出非重叠的缓冲项。 |
<B> Flowable<List<T>> |
buffer(Publisher<B> boundaryIndicator, int initialCapacity) Returns a Flowable that emits non-overlapping buffered items from the source Publisher each time the specified boundary Publisher emits an item. 返回一个Flowable,每次指定的边界Publisher发出项目时,它都会从源Publisher发出非重叠的缓冲项。 |
buffer测试用例
buffer的重载方法太多,这里不一一举例
测试代码
@Test
public void buffer3() {
System.out.println("######buffer3#####");
Flowable.just(10, 22, 13, 74, 52)
.buffer(2)//三个元素打包成一个元素
.subscribe(new Consumer<List<Integer>>() {
@Override
public void accept(List<Integer> integers) throws Exception {
System.out.println(integers.toString());
}
});
}
测试结果:
######buffer3#####
[10, 22]
[13, 74]
[52]
buffer测试用例分析
buffer操作符是把多个元素按照指定数量打包成一个元素一次过发送数据,上面测试用例实际每次把2个元素组合成一个List发送,不足2的有多少算多少.
至于其他重载方法,都是类似的作用,只是相应的配置不同。
buffer实用场景
后续完善