本文整理了Java中rx.Subscription.unsubscribe()
方法的一些代码示例,展示了Subscription.unsubscribe()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Subscription.unsubscribe()
方法的具体详情如下:
包路径:rx.Subscription
类名称:Subscription
方法名:unsubscribe
[英]Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.
This allows unregistering an Subscriber before it has finished receiving all events (i.e. before onCompleted is called).
[中]停止接收收到此订阅时注册的订阅服务器上的通知。
这允许在订阅服务器接收完所有事件之前(即在调用onCompleted之前)注销订阅服务器。
代码示例来源:origin: PipelineAI/pipeline
@Override
public void call() {
underlyingSubscription.unsubscribe();
}
});
代码示例来源:origin: PipelineAI/pipeline
@Override
public void call() {
underlyingSubscription.unsubscribe();
}
});
代码示例来源:origin: PipelineAI/pipeline
@Override
public void call() {
sourceSubscription.unsubscribe();
}
});
代码示例来源:origin: PipelineAI/pipeline
public void unsubscribe() {
originalSubscription.unsubscribe();
}
}
代码示例来源:origin: ivacf/archi
@Override
public void detachView() {
this.mainMvpView = null;
if (subscription != null) subscription.unsubscribe();
}
代码示例来源:origin: ivacf/archi
@Override
public void detachView() {
this.repositoryMvpView = null;
if (subscription != null) subscription.unsubscribe();
}
代码示例来源:origin: amitshekhariitbhu/Fast-Android-Networking
@Override
protected void onDestroy() {
super.onDestroy();
if (subscription != null) {
subscription.unsubscribe();
}
}
代码示例来源:origin: ivacf/archi
@Override
protected void onDestroy() {
super.onDestroy();
if (subscription != null) subscription.unsubscribe();
}
代码示例来源:origin: PipelineAI/pipeline
public void unsubscribe() {
Subscription s = rollingDistributionSubscription.get();
if (s != null) {
s.unsubscribe();
rollingDistributionSubscription.compareAndSet(s, null);
}
}
}
代码示例来源:origin: PipelineAI/pipeline
public void unsubscribe() {
Subscription s = rollingMaxSubscription.get();
if (s != null) {
s.unsubscribe();
rollingMaxSubscription.compareAndSet(s, null);
}
}
}
代码示例来源:origin: PipelineAI/pipeline
public void unsubscribe() {
Subscription s = subscription.get();
if (s != null) {
s.unsubscribe();
subscription.compareAndSet(s, null);
}
}
}
代码示例来源:origin: ivacf/archi
@Override
protected void onDestroy() {
super.onDestroy();
if (subscription != null) subscription.unsubscribe();
}
代码示例来源:origin: PipelineAI/pipeline
public void startCachingStreamValuesIfUnstarted() {
if (rollingMaxSubscription.get() == null) {
//the stream is not yet started
Subscription candidateSubscription = observe().subscribe(rollingMax);
if (rollingMaxSubscription.compareAndSet(null, candidateSubscription)) {
//won the race to set the subscription
} else {
//lost the race to set the subscription, so we need to cancel this one
candidateSubscription.unsubscribe();
}
}
}
代码示例来源:origin: PipelineAI/pipeline
public void startCachingStreamValuesIfUnstarted() {
if (rollingDistributionSubscription.get() == null) {
//the stream is not yet started
Subscription candidateSubscription = observe().subscribe(rollingDistribution);
if (rollingDistributionSubscription.compareAndSet(null, candidateSubscription)) {
//won the race to set the subscription
} else {
//lost the race to set the subscription, so we need to cancel this one
candidateSubscription.unsubscribe();
}
}
}
代码示例来源:origin: PipelineAI/pipeline
public void startCachingStreamValuesIfUnstarted() {
if (subscription.get() == null) {
//the stream is not yet started
Subscription candidateSubscription = observe().subscribe(counterSubject);
if (subscription.compareAndSet(null, candidateSubscription)) {
//won the race to set the subscription
} else {
//lost the race to set the subscription, so we need to cancel this one
candidateSubscription.unsubscribe();
}
}
}
代码示例来源:origin: ivacf/archi
@Override
public void destroy() {
this.context = null;
if (subscription != null && !subscription.isUnsubscribed()) subscription.unsubscribe();
}
代码示例来源:origin: ivacf/archi
@Override
public void destroy() {
if (subscription != null && !subscription.isUnsubscribed()) subscription.unsubscribe();
subscription = null;
context = null;
dataListener = null;
}
代码示例来源:origin: PipelineAI/pipeline
@Override
public void markSuccess() {
if (status.compareAndSet(Status.HALF_OPEN, Status.CLOSED)) {
//This thread wins the race to close the circuit - it resets the stream to start it over from 0
metrics.resetStream();
Subscription previousSubscription = activeSubscription.get();
if (previousSubscription != null) {
previousSubscription.unsubscribe();
}
Subscription newSubscription = subscribeToStream();
activeSubscription.set(newSubscription);
circuitOpened.set(-1L);
}
}
代码示例来源:origin: ReactiveX/RxNetty
@Test(timeout = 60000)
public void testDuplicateListeners() throws Exception {
ListenerWithSub l = holderRule.addAListener();
holderRule.assertListenerAdded(l.listener);
holderRule.getHolder().subscribe(l.listener);
assertThat("Duplicate listener added.", holderRule.getHolder().getActualListenersList(), hasSize(1));
l.subscription.unsubscribe();
assertThat("Listener not removed on unsubscribe.", holderRule.getHolder().getAllListeners(), is(empty()));
}
代码示例来源:origin: greenrobot/greenDAO
public void testOneByOneUnsubscribe() {
insertEntities(1000);
RxQuery<TestEntity> bigQuery = daoSession.getTestEntityDao().queryBuilder().rx();
TestSubscriber<TestEntity> testSubscriber = new TestSubscriber<>();
Observable<TestEntity> observable = bigQuery.oneByOne();
Subscription subscription = observable.subscribe(testSubscriber);
subscription.unsubscribe();
testSubscriber.assertUnsubscribed();
int count = testSubscriber.getValueCount();
testSubscriber.awaitTerminalEvent(100, TimeUnit.MILLISECONDS);
int count2 = testSubscriber.getValueCount();
DaoLog.d("Count 1: " + count + " vs. count 2: " + count2);
// Not strictly multi-threading correct, but anyway:
assertTrue(count2 < 1000);
}
内容来源于网络,如有侵权,请联系作者删除!