reactor.core.publisher.Flux.wrap()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中reactor.core.publisher.Flux.wrap()方法的一些代码示例,展示了Flux.wrap()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flux.wrap()方法的具体详情如下:
包路径:reactor.core.publisher.Flux
类名称:Flux
方法名:wrap

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

相关文章

Flux类方法