當前位置: 首頁>>代碼示例>>Java>>正文


Java BehaviorSubject.delay方法代碼示例

本文整理匯總了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();
}
 
開發者ID:alapshin,項目名稱:arctor,代碼行數:17,代碼來源:WaitViewReplayTransformerTest.java

示例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();
}
 
開發者ID:alapshin,項目名稱:arctor,代碼行數:17,代碼來源:WaitViewReplayTransformerTest.java

示例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();
}
 
開發者ID:alapshin,項目名稱:arctor,代碼行數:18,代碼來源:WaitViewReplayTransformerTest.java

示例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();
}
 
開發者ID:alapshin,項目名稱:arctor,代碼行數:17,代碼來源:WaitViewLatestTransformerTest.java

示例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();
}
 
開發者ID:alapshin,項目名稱:arctor,代碼行數:17,代碼來源:WaitViewLatestTransformerTest.java

示例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);
}
 
開發者ID:alapshin,項目名稱:arctor,代碼行數:17,代碼來源:WaitViewLatestTransformerTest.java

示例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();
}
 
開發者ID:alapshin,項目名稱:arctor,代碼行數:18,代碼來源:WaitViewLatestTransformerTest.java

示例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();
}
 
開發者ID:alapshin,項目名稱:arctor,代碼行數:16,代碼來源:WaitViewLatestTransformerTest.java


注:本文中的io.reactivex.subjects.BehaviorSubject.delay方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。