本文整理匯總了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"));
}
示例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"));
}
示例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);
}
示例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);
}
示例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);
}