本文整理汇总了Java中io.reactivex.CompletableObserver.onSubscribe方法的典型用法代码示例。如果您正苦于以下问题:Java CompletableObserver.onSubscribe方法的具体用法?Java CompletableObserver.onSubscribe怎么用?Java CompletableObserver.onSubscribe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.CompletableObserver
的用法示例。
在下文中一共展示了CompletableObserver.onSubscribe方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subscribeActual
import io.reactivex.CompletableObserver; //导入方法依赖的package包/类
@Override
protected void subscribeActual(final CompletableObserver completableObserver) {
verifyMainThread();
final View view = viewWeakRef.get();
if (view == null) {
completableObserver.onComplete();
return;
}
final ViewPropertyAnimatorCompat animator = ViewCompat.animate(view);
completableObserver.onSubscribe(createAnimationDisposable(animator, onAnimationCancelAction));
if (preTransformActions != null) {
applyActions(preTransformActions, animator);
animator.setDuration(NONE).setStartDelay(NONE)
.withEndAction(() -> runAnimation(completableObserver, animator))
.start();
} else {
runAnimation(completableObserver, animator);
}
}
示例2: shouldHonorDisposedWhenCallingOnComplete
import io.reactivex.CompletableObserver; //导入方法依赖的package包/类
@Test
public void shouldHonorDisposedWhenCallingOnComplete() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
CompletableObserver childObserver = mock(CompletableObserver.class);
CompletableObserver decoratedObserver = CircuitBreakerOperator.of(circuitBreaker).apply(childObserver);
decoratedObserver.onSubscribe(disposable);
// When
((Disposable) decoratedObserver).dispose();
decoratedObserver.onComplete();
// Then
verify(childObserver, never()).onComplete();
assertSingleSuccessfulCall();
}
示例3: shouldHonorDisposedWhenCallingOnError
import io.reactivex.CompletableObserver; //导入方法依赖的package包/类
@Test
public void shouldHonorDisposedWhenCallingOnError() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
CompletableObserver childObserver = mock(CompletableObserver.class);
CompletableObserver decoratedObserver = CircuitBreakerOperator.of(circuitBreaker).apply(childObserver);
decoratedObserver.onSubscribe(disposable);
// When
((Disposable) decoratedObserver).dispose();
decoratedObserver.onError(new IllegalStateException());
// Then
verify(childObserver, never()).onError(any());
assertSingleFailedCall();
}
示例4: shouldHonorDisposedWhenCallingOnComplete
import io.reactivex.CompletableObserver; //导入方法依赖的package包/类
@Test
public void shouldHonorDisposedWhenCallingOnComplete() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
CompletableObserver childObserver = mock(CompletableObserver.class);
CompletableObserver decoratedObserver = BulkheadOperator.of(bulkhead).apply(childObserver);
decoratedObserver.onSubscribe(disposable);
// When
((Disposable) decoratedObserver).dispose();
decoratedObserver.onComplete();
// Then
verify(childObserver, never()).onComplete();
assertThat(bulkhead.getMetrics().getAvailableConcurrentCalls()).isEqualTo(1);
}
示例5: shouldHonorDisposedWhenCallingOnError
import io.reactivex.CompletableObserver; //导入方法依赖的package包/类
@Test
public void shouldHonorDisposedWhenCallingOnError() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
CompletableObserver childObserver = mock(CompletableObserver.class);
CompletableObserver decoratedObserver = BulkheadOperator.of(bulkhead).apply(childObserver);
decoratedObserver.onSubscribe(disposable);
// When
((Disposable) decoratedObserver).dispose();
decoratedObserver.onError(new IllegalStateException());
// Then
verify(childObserver, never()).onError(any());
assertThat(bulkhead.getMetrics().getAvailableConcurrentCalls()).isEqualTo(1);
}
示例6: shouldNotReleaseBulkheadWhenWasDisposedAfterNotPermittedSubscribe
import io.reactivex.CompletableObserver; //导入方法依赖的package包/类
@Test
public void shouldNotReleaseBulkheadWhenWasDisposedAfterNotPermittedSubscribe() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
CompletableObserver childObserver = mock(CompletableObserver.class);
CompletableObserver decoratedObserver = BulkheadOperator.of(bulkhead).apply(childObserver);
bulkhead.isCallPermitted();
assertThat(bulkhead.getMetrics().getAvailableConcurrentCalls()).isEqualTo(0);
decoratedObserver.onSubscribe(disposable);
// When
((Disposable) decoratedObserver).dispose();
// Then
assertThat(bulkhead.getMetrics().getAvailableConcurrentCalls()).isEqualTo(0);
}
示例7: subscribeActual
import io.reactivex.CompletableObserver; //导入方法依赖的package包/类
@Override
protected void subscribeActual(final CompletableObserver completableObserver) {
verifyMainThread();
final UpdateListener updateListener = new UpdateListener(completableObserver, valueUpdateAction);
final AnimationEndListener endListener = new AnimationEndListener(completableObserver, valueAnimator, animationCancelAction);
final ValueAnimatorDisposable animatorDisposable = new ValueAnimatorDisposable(valueAnimator, updateListener, endListener);
completableObserver.onSubscribe(animatorDisposable);
valueAnimator.addUpdateListener(updateListener);
valueAnimator.addListener(endListener);
valueAnimator.start();
}
示例8: subscribeActual
import io.reactivex.CompletableObserver; //导入方法依赖的package包/类
@Override
protected void subscribeActual(CompletableObserver observer) {
Task<Void> task = run();
CompletableTaskCallback callback = new CompletableTaskCallback(task, observer);
observer.onSubscribe(callback);
task.addOnCompleteListener(callback);
}
示例9: shouldNotAffectCircuitBreakerWhenWasDisposedAfterNotPermittedSubscribe
import io.reactivex.CompletableObserver; //导入方法依赖的package包/类
@Test
public void shouldNotAffectCircuitBreakerWhenWasDisposedAfterNotPermittedSubscribe() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
CompletableObserver childObserver = mock(CompletableObserver.class);
CompletableObserver decoratedObserver = CircuitBreakerOperator.of(circuitBreaker).apply(childObserver);
circuitBreaker.transitionToOpenState();
decoratedObserver.onSubscribe(disposable);
// When
((Disposable) decoratedObserver).dispose();
// Then
assertNoRegisteredCall();
}