本文整理匯總了Java中io.reactivex.subjects.BehaviorSubject.delay方法的典型用法代碼示例。如果您正苦於以下問題:Java BehaviorSubject.delay方法的具體用法?Java BehaviorSubject.delay怎麽用?Java BehaviorSubject.delay使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.reactivex.subjects.BehaviorSubject
的用法示例。
在下文中一共展示了BehaviorSubject.delay方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: shouldEmitValueAfterViewIsAttached
import io.reactivex.subjects.BehaviorSubject; //導入方法依賴的package包/類
@Test
public void shouldEmitValueAfterViewIsAttached() {
TestScheduler testScheduler = new TestScheduler();
BehaviorSubject<Boolean> view = BehaviorSubject.create();
view.onNext(true);
WaitViewReplayTransformer<Integer> transformer = new WaitViewReplayTransformer<>(
view.delay(EMIT_DELAY_IN_SECONDS, TimeUnit.SECONDS, testScheduler));
TestObserver<Integer> testObserver = Observable.just(0)
.compose(transformer)
.test();
testScheduler.advanceTimeBy(EMIT_DELAY_IN_SECONDS, TimeUnit.SECONDS);
testObserver.awaitTerminalEvent();
testObserver.assertValue(0);
testObserver.assertComplete();
}
示例2: shouldReplayAllValuesAfterViewIsAttached
import io.reactivex.subjects.BehaviorSubject; //導入方法依賴的package包/類
@Test
public void shouldReplayAllValuesAfterViewIsAttached() {
TestScheduler testScheduler = new TestScheduler();
BehaviorSubject<Boolean> view = BehaviorSubject.create();
view.onNext(true);
WaitViewReplayTransformer<Integer> transformer = new WaitViewReplayTransformer<>(
view.delay(EMIT_DELAY_IN_SECONDS, TimeUnit.SECONDS, testScheduler));
TestObserver<Integer> testObserver = Observable.just(0, 1, 2)
.compose(transformer)
.test();
testScheduler.advanceTimeBy(EMIT_DELAY_IN_SECONDS, TimeUnit.SECONDS);
testObserver.awaitTerminalEvent();
testObserver.assertValues(0, 1, 2);
testObserver.assertComplete();
}
示例3: shouldEmitErrorAfterViewIsAttached
import io.reactivex.subjects.BehaviorSubject; //導入方法依賴的package包/類
@Test
public void shouldEmitErrorAfterViewIsAttached() {
TestScheduler testScheduler = new TestScheduler();
BehaviorSubject<Boolean> view = BehaviorSubject.create();
view.onNext(true);
WaitViewReplayTransformer<Integer> transformer = new WaitViewReplayTransformer<>(
view.delay(EMIT_DELAY_IN_SECONDS, TimeUnit.SECONDS, testScheduler));
Exception exception = new RuntimeException();
TestObserver<Integer> testObserver = Observable.<Integer>error(exception)
.compose(transformer)
.test();
testScheduler.advanceTimeBy(EMIT_DELAY_IN_SECONDS, TimeUnit.SECONDS);
testObserver.awaitTerminalEvent();
testObserver.assertError(exception);
testObserver.assertNotComplete();
}
示例4: shouldEmitValueAfterViewIsAttached
import io.reactivex.subjects.BehaviorSubject; //導入方法依賴的package包/類
@Test
public void shouldEmitValueAfterViewIsAttached() {
TestScheduler testScheduler = new TestScheduler();
BehaviorSubject<Boolean> view = BehaviorSubject.create();
view.onNext(true);
WaitViewLatestTransformer<Integer> transformer =
new WaitViewLatestTransformer<>(view.delay(EMIT_DELAY_IN_SECONDS, TimeUnit.SECONDS, testScheduler));
TestObserver<Integer> testObserver = Observable.just(0)
.compose(transformer)
.test();
testScheduler.advanceTimeBy(EMIT_DELAY_IN_SECONDS, TimeUnit.SECONDS);
testObserver.awaitTerminalEvent();
testObserver.assertValue(0);
testObserver.assertComplete();
}
示例5: shouldEmitLatestValueAfterViewIsAttached
import io.reactivex.subjects.BehaviorSubject; //導入方法依賴的package包/類
@Test
public void shouldEmitLatestValueAfterViewIsAttached() {
TestScheduler testScheduler = new TestScheduler();
BehaviorSubject<Boolean> view = BehaviorSubject.create();
view.onNext(true);
WaitViewLatestTransformer<Integer> transformer =
new WaitViewLatestTransformer<>(view.delay(EMIT_DELAY_IN_SECONDS, TimeUnit.SECONDS, testScheduler));
TestObserver<Integer> testObserver = Observable.fromArray(0, 1, 2)
.compose(transformer)
.test();
testScheduler.advanceTimeBy(EMIT_DELAY_IN_SECONDS, TimeUnit.SECONDS);
testObserver.awaitTerminalEvent();
testObserver.assertValue(2);
testObserver.assertComplete();
}
示例6: shouldEmitErrorAfterViewIsAttached
import io.reactivex.subjects.BehaviorSubject; //導入方法依賴的package包/類
@Test
public void shouldEmitErrorAfterViewIsAttached() {
TestScheduler testScheduler = new TestScheduler();
BehaviorSubject<Boolean> view = BehaviorSubject.create();
view.onNext(true);
WaitViewLatestTransformer<Integer> transformer =
new WaitViewLatestTransformer<>(view.delay(EMIT_DELAY_IN_SECONDS, TimeUnit.SECONDS, testScheduler));
Exception exception = new RuntimeException();
TestObserver<Integer> testObserver = Observable.<Integer>error(exception)
.compose(transformer)
.test();
testScheduler.advanceTimeBy(EMIT_DELAY_IN_SECONDS, TimeUnit.SECONDS);
testObserver.awaitTerminalEvent();
testObserver.assertError(exception);
}
示例7: shouldEmitLatestValueFromEndlessWithSingleEmissionAfterViewIsAttached
import io.reactivex.subjects.BehaviorSubject; //導入方法依賴的package包/類
@Test
public void shouldEmitLatestValueFromEndlessWithSingleEmissionAfterViewIsAttached() {
TestScheduler testScheduler = new TestScheduler();
BehaviorSubject<Boolean> view = BehaviorSubject.create();
view.onNext(true);
WaitViewLatestTransformer<Integer> transformer =
new WaitViewLatestTransformer<>(view.delay(EMIT_DELAY_IN_SECONDS, TimeUnit.SECONDS, testScheduler));
BehaviorSubject<Integer> subject = BehaviorSubject.create();
subject.onNext(1);
TestObserver<Integer> testObserver = subject
.compose(transformer)
.test();
testScheduler.advanceTimeBy(EMIT_DELAY_IN_SECONDS, TimeUnit.SECONDS);
testObserver.assertValue(1);
testObserver.assertNotComplete();
}
示例8: shouldEmitValueFromEndlessAfterViewIsAttached
import io.reactivex.subjects.BehaviorSubject; //導入方法依賴的package包/類
@Test
public void shouldEmitValueFromEndlessAfterViewIsAttached() {
TestScheduler testScheduler = new TestScheduler();
BehaviorSubject<Boolean> view = BehaviorSubject.create();
view.onNext(true);
WaitViewLatestTransformer<Long> transformer =
new WaitViewLatestTransformer<>(view.delay(EMIT_DELAY_IN_SECONDS, TimeUnit.SECONDS, testScheduler));
TestObserver<Long> testObserver =
Observable.interval(0, 100, TimeUnit.SECONDS, testScheduler)
.compose(transformer)
.test();
testScheduler.advanceTimeBy(500, TimeUnit.SECONDS);
testObserver.assertNotComplete();
assertThat(testObserver.getEvents()).isNotEmpty();
}