当前位置: 首页>>代码示例>>Java>>正文


Java PublishSubject.compose方法代码示例

本文整理汇总了Java中rx.subjects.PublishSubject.compose方法的典型用法代码示例。如果您正苦于以下问题:Java PublishSubject.compose方法的具体用法?Java PublishSubject.compose怎么用?Java PublishSubject.compose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rx.subjects.PublishSubject的用法示例。


在下文中一共展示了PublishSubject.compose方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPairTakeWhen_sourceEmitsFirst

import rx.subjects.PublishSubject; //导入方法依赖的package包/类
@Test
public void testPairTakeWhen_sourceEmitsFirst() {

  final PublishSubject<Integer> source = PublishSubject.create();
  final PublishSubject<String> sample = PublishSubject.create();
  final Observable<Pair<Integer, String>> pair = source.compose(Transformers.takePairWhen(sample));

  final TestSubscriber<Pair<Integer, String>> resultTest = TestSubscriber.create();
  pair.subscribe(resultTest);

  source.onNext(1);
  resultTest.assertNoValues();

  source.onNext(2);
  resultTest.assertNoValues();

  sample.onNext("a");
  resultTest.assertValues(Pair.create(2, "a"));

  sample.onNext("b");
  resultTest.assertValues(Pair.create(2, "a"), Pair.create(2, "b"));

  source.onNext(3);
  resultTest.assertValues(Pair.create(2, "a"), Pair.create(2, "b"));

  sample.onNext("c");
  resultTest.assertValues(Pair.create(2, "a"), Pair.create(2, "b"), Pair.create(3, "c"));
}
 
开发者ID:kickstarter,项目名称:android-oss,代码行数:29,代码来源:TakePairWhenTransformerTest.java

示例2: testPairTakeWhen_sourceEmitsSecond

import rx.subjects.PublishSubject; //导入方法依赖的package包/类
@Test
public void testPairTakeWhen_sourceEmitsSecond() {

  final PublishSubject<Integer> source = PublishSubject.create();
  final PublishSubject<String> sample = PublishSubject.create();
  final Observable<Pair<Integer, String>> pair = source.compose(Transformers.takePairWhen(sample));

  final TestSubscriber<Pair<Integer, String>> resultTest = TestSubscriber.create();
  pair.subscribe(resultTest);

  sample.onNext("a");
  resultTest.assertNoValues();

  sample.onNext("b");
  resultTest.assertNoValues();

  source.onNext(1);
  resultTest.assertNoValues();

  sample.onNext("c");
  resultTest.assertValues(Pair.create(1, "c"));

  source.onNext(2);
  resultTest.assertValues(Pair.create(1, "c"));

  sample.onNext("d");
  resultTest.assertValues(Pair.create(1, "c"), Pair.create(2, "d"));
}
 
开发者ID:kickstarter,项目名称:android-oss,代码行数:29,代码来源:TakePairWhenTransformerTest.java

示例3: testTakeWhen_sourceEmitsFirst

import rx.subjects.PublishSubject; //导入方法依赖的package包/类
@Test
public void testTakeWhen_sourceEmitsFirst() {

  final PublishSubject<Integer> source = PublishSubject.create();
  final PublishSubject<Void> sample = PublishSubject.create();
  final Observable<Integer> result = source.compose(Transformers.takeWhen(sample));

  final TestSubscriber<Integer> resultTest = new TestSubscriber<>();
  result.subscribe(resultTest);

  source.onNext(1);
  resultTest.assertNoValues();

  source.onNext(2);
  resultTest.assertNoValues();

  sample.onNext(null);
  resultTest.assertValues(2);

  sample.onNext(null);
  resultTest.assertValues(2, 2);

  source.onNext(3);
  resultTest.assertValues(2, 2);

  sample.onNext(null);
  resultTest.assertValues(2, 2, 3);
}
 
开发者ID:kickstarter,项目名称:android-oss,代码行数:29,代码来源:TakeWhenTransformerTest.java

示例4: testTakeWhen_sourceEmitsSecond

import rx.subjects.PublishSubject; //导入方法依赖的package包/类
@Test
public void testTakeWhen_sourceEmitsSecond() {

  final PublishSubject<Integer> source = PublishSubject.create();
  final PublishSubject<Void> sample = PublishSubject.create();
  final Observable<Integer> result = source.compose(Transformers.takeWhen(sample));

  final TestSubscriber<Integer> resultTest = new TestSubscriber<>();
  result.subscribe(resultTest);

  sample.onNext(null);
  resultTest.assertNoValues();

  sample.onNext(null);
  resultTest.assertNoValues();

  source.onNext(1);
  resultTest.assertNoValues();

  sample.onNext(null);
  resultTest.assertValues(1);

  source.onNext(2);
  resultTest.assertValues(1);

  sample.onNext(null);
  resultTest.assertValues(1, 2);

  source.onNext(3);
  resultTest.assertValues(1, 2);

  sample.onNext(null);
  resultTest.assertValues(1, 2, 3);
}
 
开发者ID:kickstarter,项目名称:android-oss,代码行数:35,代码来源:TakeWhenTransformerTest.java

示例5: testCoalesceTransformer

import rx.subjects.PublishSubject; //导入方法依赖的package包/类
@Test
public void testCoalesceTransformer() {
  final Integer theDefault = 100;
  final PublishSubject<Integer> source = PublishSubject.create();
  final Observable<Integer> result = source
    .compose(coalesce(theDefault));

  final TestSubscriber<Integer> resultTest = TestSubscriber.create();
  result.subscribe(resultTest);

  source.onNext(1);
  resultTest.assertValue(1);

  source.onNext(2);
  resultTest.assertValues(1, 2);

  source.onNext(null);
  resultTest.assertValues(1, 2, theDefault);
}
 
开发者ID:kickstarter,项目名称:android-oss,代码行数:20,代码来源:CoalesceTransformerTest.java


注:本文中的rx.subjects.PublishSubject.compose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。