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

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

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

Observable.mergeWith介绍

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

Scheduler: mergeWith does not operate by default on a particular Scheduler.
[中]中继此可观察项,仅当其他CompletableSource也完成时才完成。
调度程序:默认情况下,mergeWith不会在特定调度程序上运行。

代码示例

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

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

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

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

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

@Test(expected = NullPointerException.class)
public void mergeWithNull() {
  just1.mergeWith((ObservableSource<Integer>)null);
}

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

@Override
  public Observable<String> apply(final String s) {
    return Observable.just(s)
        .mergeWith(Observable.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 testMergeWith() {
  TestObserver<Integer> to = new TestObserver<Integer>();
  Observable.just(1).mergeWith(Observable.just(2)).subscribe(to);
  to.assertValues(1, 2);
}

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

@Test
public void normal() {
  final TestObserver<Integer> to = new TestObserver<Integer>();
  Observable.range(1, 5).mergeWith(
      Completable.fromAction(new Action() {
        @Override
        public void run() throws Exception {
          to.onNext(100);
        }
      })
  )
  .subscribe(to);
  to.assertResult(1, 2, 3, 4, 5, 100);
}

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

@Test
public void take() {
  final TestObserver<Integer> to = new TestObserver<Integer>();
  Observable.range(1, 5).mergeWith(
      Completable.complete()
  )
  .take(3)
  .subscribe(to);
  to.assertResult(1, 2, 3);
}

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

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

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

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

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

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

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

@Test
public void mainError() {
  Observable.error(new TestException())
  .mergeWith(Completable.complete())
  .test()
  .assertFailure(TestException.class);
}

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

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

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

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

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

@Test
public void mainError() {
  Observable.error(new TestException())
  .mergeWith(Single.just(100))
  .test()
  .assertFailure(TestException.class);
}

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

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

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

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

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

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

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

@Test
public void mainError() {
  Observable.error(new TestException())
  .mergeWith(Maybe.just(100))
  .test()
  .assertFailure(TestException.class);
}

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

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

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

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

相关文章

Observable类方法