本文整理汇总了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!")
);
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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));
}
示例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();
}
示例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));
}
示例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();
}
示例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));
}
示例11: safeComplete
import io.reactivex.subjects.Subject; //导入方法依赖的package包/类
public static <T> void safeComplete(@NonNull Subject<T> emitter) {
if (!emitter.hasThrowable() && !emitter.hasComplete()) {
emitter.onComplete();
}
}