本文整理了Java中reactor.core.publisher.Flux.wrap()
方法的一些代码示例,展示了Flux.wrap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flux.wrap()
方法的具体详情如下:
包路径:reactor.core.publisher.Flux
类名称:Flux
方法名:wrap
[英]Unchecked wrap of Publisher as Flux, supporting Fuseable sources
[中]未经检查的发布服务器包装为Flux,支持可融合源
代码示例来源:origin: reactor/reactor-core
/**
* Convert this {@link Mono} to a {@link Flux}
*
* @return a {@link Flux} variant of this {@link Mono}
*/
public final Flux<T> flux() {
if (this instanceof Callable) {
if (this instanceof Fuseable.ScalarCallable) {
T v;
try {
v = block();
}
catch (Throwable t) {
return Flux.error(t);
}
if (v == null) {
return Flux.empty();
}
return Flux.just(v);
}
@SuppressWarnings("unchecked") Callable<T> thiz = (Callable<T>) this;
return Flux.onAssembly(new FluxCallable<>(thiz));
}
return Flux.wrap(this);
}
代码示例来源:origin: reactor/reactor-core
return wrap(source);
代码示例来源:origin: reactor/reactor-core
@Test
public void wrap() {
Flux<Integer> m = Flux.wrap(Flux.just(1));
StepVerifier.create(m)
.expectNext(1)
.verifyComplete();
m = Flux.wrap(Flux.just(1).hide());
StepVerifier.create(m)
.expectNext(1)
.verifyComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void conditionalFusionAvailableWithFuseable() {
AssertSubscriber<Object> ts = AssertSubscriber.create();
Flux.wrap(u -> {
if (!(u instanceof Fuseable.ConditionalSubscriber)) {
Operators.error(u,
new IllegalArgumentException("The subscriber is not conditional: " + u));
}
else {
Operators.complete(u);
}
})
.doOnNext(v -> {
})
.filter(v -> true)
.subscribe(ts);
ts.assertNoError()
.assertNoValues()
.assertComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void conditionalFusionAvailableWithFuseable() {
AssertSubscriber<Object> ts = AssertSubscriber.create();
Flux.wrap(u -> {
if (!(u instanceof Fuseable.ConditionalSubscriber)) {
Operators.error(u,
new IllegalArgumentException("The subscriber is not conditional: " + u));
}
else {
Operators.complete(u);
}
})
.doOnNext(v -> {
})
.filter(v -> true)
.subscribe(ts);
ts.assertNoError()
.assertNoValues()
.assertComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void conditionalFusionAvailable() {
AssertSubscriber<Object> ts = AssertSubscriber.create();
Flux.wrap(u -> {
if (!(u instanceof Fuseable.ConditionalSubscriber)) {
Operators.error(u,
new IllegalArgumentException("The subscriber is not conditional: " + u));
}
else {
Operators.complete(u);
}
})
.doOnNext(v -> {
})
.filter(v -> true)
.subscribe(ts);
ts.assertNoError()
.assertNoValues()
.assertComplete();
}
代码示例来源:origin: io.projectreactor/reactor-core
/**
* Convert this {@link Mono} to a {@link Flux}
*
* @return a {@link Flux} variant of this {@link Mono}
*/
public final Flux<T> flux() {
if (this instanceof Callable) {
if (this instanceof Fuseable.ScalarCallable) {
T v;
try {
v = block();
}
catch (Throwable t) {
return Flux.error(t);
}
if (v == null) {
return Flux.empty();
}
return Flux.just(v);
}
@SuppressWarnings("unchecked") Callable<T> thiz = (Callable<T>) this;
return Flux.onAssembly(new FluxCallable<>(thiz));
}
return Flux.wrap(this);
}
代码示例来源:origin: io.projectreactor/reactor-core
return wrap(source);
内容来源于网络,如有侵权,请联系作者删除!