本文整理汇总了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);
}