當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。