本文整理汇总了Java中reactor.core.publisher.BaseSubscriber类的典型用法代码示例。如果您正苦于以下问题:Java BaseSubscriber类的具体用法?Java BaseSubscriber怎么用?Java BaseSubscriber使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BaseSubscriber类属于reactor.core.publisher包,在下文中一共展示了BaseSubscriber类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import reactor.core.publisher.BaseSubscriber; //导入依赖的package包/类
@Test
public void test() throws Exception {
AtomicLong counter = new AtomicLong(0L);
Scheduler scheduler = new ParallelScheduler(10);
Flowable
.<Long>generate(sink -> sink.onNext(counter.getAndIncrement()))
.concatMap(i -> {
return Flowable.just(i)
.observeOn(scheduler)
.map(number -> number * 2L);
})
.subscribeOn(new SingleScheduler())
.subscribe(new BaseSubscriber<Long>() {
@Override
protected void hookOnSubscribe(Subscription subscription) {
subscription.request(10);
}
@Override
protected void hookOnNext(Long value) {
upstream().request(1);
}
});
Thread.sleep(100000000);
}
示例2: baseSubscriberFineTuneBackpressure
import reactor.core.publisher.BaseSubscriber; //导入依赖的package包/类
@Test
public void baseSubscriberFineTuneBackpressure() {
Flux<String> source = someStringSource();
source.map(String::toUpperCase)
.subscribe(new BaseSubscriber<String>() { // <1>
@Override
protected void hookOnSubscribe(Subscription subscription) {
// <2>
request(1); // <3>
}
@Override
protected void hookOnNext(String value) {
request(1); // <4>
}
//<5>
});
}