io.reactivex.Flowable.mergeWith()方法的使用及代码示例

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

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

Flowable.mergeWith介绍

[英]Relays the items of this Flowable and completes only when the other CompletableSource completes as well.

Backpressure: The operator doesn't interfere with backpressure which is determined by the source Publisher's backpressure behavior. Scheduler: mergeWith does not operate by default on a particular Scheduler.
[中]中继此可流动的项,并仅在其他CompletableSource也完成时完成。
背压:操作员不会干扰由源发布者的背压行为确定的背压。调度程序:默认情况下,mergeWith不会在特定调度程序上运行。

代码示例

代码示例来源:origin: ReactiveX/RxJava

@Override
  public Publisher<Object> apply(Flowable<Object> f)
      throws Exception {
    return f.mergeWith(Single.just(1));
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public Publisher<Object> apply(Flowable<Object> f)
      throws Exception {
    return f.mergeWith(Maybe.just(1));
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public Publisher<Long> createPublisher(long elements) {
    if (elements == 0) {
      return Flowable.<Long>empty()
          .mergeWith(Maybe.<Long>empty());
    }
    return
      Flowable.rangeLong(1, elements - 1)
      .mergeWith(Maybe.just(elements))
    ;
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public Publisher<Long> createPublisher(long elements) {
    return
      Flowable.rangeLong(1, elements)
      .mergeWith(Completable.complete())
    ;
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public Publisher<Long> createPublisher(long elements) {
    return
      Flowable.rangeLong(1, elements)
      .mergeWith(Maybe.<Long>empty())
    ;
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public Flowable<String> apply(final String s) {
    return Flowable.just(s)
        .mergeWith(Flowable.interval(10, TimeUnit.MILLISECONDS)
        .map(new Function<Long, String>() {
          @Override
          public String apply(Long i) {
            return s + " " + i;
          }
        })).take(250);
  }
})

代码示例来源:origin: ReactiveX/RxJava

@Test
public void normal() {
  Flowable.range(1, 5)
  .mergeWith(Maybe.just(100))
  .test()
  .assertResult(1, 2, 3, 4, 5, 100);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void normal() {
  Flowable.range(1, 5)
  .mergeWith(Single.just(100))
  .test()
  .assertResult(1, 2, 3, 4, 5, 100);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void emptyOther() {
  Flowable.range(1, 5)
  .mergeWith(Maybe.<Integer>empty())
  .test()
  .assertResult(1, 2, 3, 4, 5);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void testMergeWith() {
  TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
  Flowable.just(1).mergeWith(Flowable.just(2)).subscribe(ts);
  ts.assertValues(1, 2);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void take() {
  Flowable.range(1, 5)
  .mergeWith(Single.just(100))
  .take(3)
  .test()
  .assertResult(1, 2, 3);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void normalLongRequestExact() {
  Flowable.range(1, 512)
  .mergeWith(Maybe.just(100))
  .test(513)
  .assertValueCount(513)
  .assertComplete();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void take() {
  Flowable.range(1, 5)
  .mergeWith(Maybe.just(100))
  .take(3)
  .test()
  .assertResult(1, 2, 3);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void noRequestOnError() {
  Flowable.empty()
  .mergeWith(Maybe.error(new TestException()))
  .test(0)
  .assertFailure(TestException.class);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void noRequestOnError() {
  Flowable.empty()
  .mergeWith(Single.error(new TestException()))
  .test(0)
  .assertFailure(TestException.class);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void take() {
  Flowable.range(1, 5)
  .mergeWith(Completable.complete())
  .take(3)
  .test()
  .assertResult(1, 2, 3);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void otherError() {
  Flowable.never()
  .mergeWith(Maybe.error(new TestException()))
  .test()
  .assertFailure(TestException.class);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void normalLongRequestExact() {
  Flowable.range(1, 512)
  .mergeWith(Single.just(100))
  .test(513)
  .assertValueCount(513)
  .assertComplete();
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void otherError() {
  Flowable.never()
  .mergeWith(Completable.error(new TestException()))
  .test()
  .assertFailure(TestException.class);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void normalLong() {
  Flowable.range(1, 512)
  .mergeWith(Maybe.just(100))
  .test()
  .assertValueCount(513)
  .assertComplete();
}

相关文章

Flowable类方法