Skip to content

Commit

Permalink
处理重复的订阅回调,线程切换时,不再重复注册。
Browse files Browse the repository at this point in the history
  • Loading branch information
liudawei committed Jan 6, 2020
1 parent 0ad72f8 commit 50791a2
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public ObservableObserveOn(ObservableSource<T> source, Scheduler scheduler) {
@Override
protected void subscribeActual(Observer<T> observer) {
ObserverOnObserver observeOn = new ObserverOnObserver(observer);
observer.onSubscribe();
source.subscribe(observeOn);
scheduler.scheduleDirect(observeOn);
}
Expand Down Expand Up @@ -57,6 +56,9 @@ public void onError(Throwable t) {

@Override
public void onSubscribe() {
if(!isSubscribed.compareAndSet(false,true)){
return;
}
actual.onSubscribe();
}

Expand Down

0 comments on commit 50791a2

Please sign in to comment.