当前位置: 首页>>代码示例>>Java>>正文


Java Subject.onComplete方法代码示例

本文整理汇总了Java中io.reactivex.subjects.Subject.onComplete方法的典型用法代码示例。如果您正苦于以下问题:Java Subject.onComplete方法的具体用法?Java Subject.onComplete怎么用?Java Subject.onComplete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.reactivex.subjects.Subject的用法示例。


在下文中一共展示了Subject.onComplete方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import io.reactivex.subjects.Subject; //导入方法依赖的package包/类
public static void main(String[] args) {
    Subject<String> subject =
            AsyncSubject.create();
    subject.subscribe(s ->
                    System.out.println("Observer 1: " + s),
            Throwable::printStackTrace,
            () -> System.out.println("Observer 1 done!")
    );
    subject.onNext("Alpha");
    subject.onNext("Beta");
    subject.onNext("Gamma");
    subject.onComplete();
    subject.subscribe(s ->
                    System.out.println("Observer 2: " + s),
            Throwable::printStackTrace,
            () -> System.out.println("Observer 2 done!")
    );
}
 
开发者ID:PacktPublishing,项目名称:Learning-RxJava,代码行数:19,代码来源:Ch5_25.java

示例2: emitsOnCompleteWhenBoundTriggerIsCompleted

import io.reactivex.subjects.Subject; //导入方法依赖的package包/类
@Test
public void emitsOnCompleteWhenBoundTriggerIsCompleted() {
    // given
    Subject<NoParameter> trigger = PublishSubject.create();
    RxCommand<NoParameter> command = new RxCommand<NoParameter>()
            .bindTrigger(trigger);
    TestObserver<NoParameter> testObserver = command.test();

    // when
    trigger.onNext(NoParameter.INSTANCE);
    trigger.onComplete();

    // then
    testObserver.assertResult(NoParameter.INSTANCE)
            .dispose();

    // after
    command.dispose();
}
 
开发者ID:k-kagurazaka,项目名称:rx-property-android,代码行数:20,代码来源:RxCommandTest.java

示例3: noLongerNotifyWhenSourceObservableIsCompleted

import io.reactivex.subjects.Subject; //导入方法依赖的package包/类
@Test
public void noLongerNotifyWhenSourceObservableIsCompleted() {
    // given
    Subject<String> source = PublishSubject.create();
    property = new RxProperty<>(source);
    TestObserver<String> testObserver = propertyObserver(property);

    // when
    source.onNext("First");
    source.onComplete();
    source.onNext("Second");

    // then
    testObserver.assertSubscribed()
            .assertValue("First")
            .assertNoErrors()
            .assertNotComplete()
            .dispose();
}
 
开发者ID:k-kagurazaka,项目名称:rx-property-android,代码行数:20,代码来源:RxPropertyTest.java

示例4: errorObservablesEmitOnCompleteWhenSourceObservableIsCompleted

import io.reactivex.subjects.Subject; //导入方法依赖的package包/类
@Test
public void errorObservablesEmitOnCompleteWhenSourceObservableIsCompleted() {
    // given
    Subject<String> source = PublishSubject.create();
    property = new RxProperty<>(source);
    property.setValidator(new AllSuccessValidator());
    testObserver = new RxPropertyErrorObserver<>(property);

    // when
    source.onComplete();

    // then
    testObserver.assertNoErrors()
            .assertNoSummarizedErrors()
            .assertNoHasErrors()
            .assertComplete()
            .dispose();
}
 
开发者ID:k-kagurazaka,项目名称:rx-property-android,代码行数:19,代码来源:RxPropertyTest.java

示例5: main

import io.reactivex.subjects.Subject; //导入方法依赖的package包/类
public static void main(String[] args) {
    Subject<String> subject = PublishSubject.create();
    subject.onNext("Alpha");
    subject.onNext("Beta");
    subject.onNext("Gamma");
    subject.onComplete();
    subject.map(String::length)
            .subscribe(System.out::println);
}
 
开发者ID:PacktPublishing,项目名称:Learning-RxJava,代码行数:10,代码来源:Ch5_22.java

示例6: main

import io.reactivex.subjects.Subject; //导入方法依赖的package包/类
public static void main(String[] args) {
    Subject<String> subject =
            ReplaySubject.create();
    subject.subscribe(s -> System.out.println("Observer 1: " +
            s));
    subject.onNext("Alpha");
    subject.onNext("Beta");
    subject.onNext("Gamma");
    subject.onComplete();
    subject.subscribe(s -> System.out.println("Observer 2: " +
            s));
}
 
开发者ID:PacktPublishing,项目名称:Learning-RxJava,代码行数:13,代码来源:Ch5_24.java

示例7: main

import io.reactivex.subjects.Subject; //导入方法依赖的package包/类
public static void main(String[] args) {
    Subject<String> subject = PublishSubject.create();
    subject.map(String::length)
            .subscribe(System.out::println);
    subject.onNext("Alpha");
    subject.onNext("Beta");
    subject.onNext("Gamma");
    subject.onComplete();
}
 
开发者ID:PacktPublishing,项目名称:Learning-RxJava,代码行数:10,代码来源:Ch5_20.java

示例8: autoDisposedWhenBoundTriggerIsCompleted

import io.reactivex.subjects.Subject; //导入方法依赖的package包/类
@Test
public void autoDisposedWhenBoundTriggerIsCompleted() {
    // given
    Subject<NoParameter> trigger = PublishSubject.create();
    RxCommand<NoParameter> command = new RxCommand<NoParameter>()
            .bindTrigger(trigger);

    // when
    trigger.onComplete();

    // then
    assertThat(command.isDisposed(), is(true));
}
 
开发者ID:k-kagurazaka,项目名称:rx-property-android,代码行数:14,代码来源:RxCommandTest.java

示例9: emitsOnCompleteWhenSourceObservableIsCompleted

import io.reactivex.subjects.Subject; //导入方法依赖的package包/类
@Test
public void emitsOnCompleteWhenSourceObservableIsCompleted() {
    // given
    Subject<String> source = PublishSubject.create();
    property = new RxProperty<>(source);
    TestObserver<String> testObserver = property.test();

    // when
    source.onComplete();

    // then
    testObserver.assertResult().dispose();
}
 
开发者ID:k-kagurazaka,项目名称:rx-property-android,代码行数:14,代码来源:RxPropertyTest.java

示例10: returnsTrueAfterSourceObservableIsCompleted

import io.reactivex.subjects.Subject; //导入方法依赖的package包/类
@Test
public void returnsTrueAfterSourceObservableIsCompleted() {
    // given
    Subject<String> source = PublishSubject.create();
    property = new RxProperty<>(source);

    // when
    source.onComplete();

    // then
    assertThat(property.isDisposed(), is(true));
}
 
开发者ID:k-kagurazaka,项目名称:rx-property-android,代码行数:13,代码来源:RxPropertyTest.java

示例11: safeComplete

import io.reactivex.subjects.Subject; //导入方法依赖的package包/类
public static <T> void safeComplete(@NonNull Subject<T> emitter) {
    if (!emitter.hasThrowable() && !emitter.hasComplete()) {
        emitter.onComplete();
    }
}
 
开发者ID:k-kagurazaka,项目名称:rx-property-android,代码行数:6,代码来源:Helper.java


注:本文中的io.reactivex.subjects.Subject.onComplete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。