Skip to content

Commit

Permalink
Merge pull request #3091 from akarnokd/AutoConnectFix
Browse files Browse the repository at this point in the history
Fix autoConnect calling onStart twice.
  • Loading branch information
benjchristensen committed Jul 20, 2015
2 parents e4000b3 + d43b3d1 commit 29b9de2
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
import java.util.concurrent.atomic.AtomicInteger;

import rx.Observable.OnSubscribe;
import rx.*;
import rx.Subscriber;
import rx.Subscription;
import rx.functions.Action1;
import rx.observables.ConnectableObservable;
import rx.observers.Subscribers;

/**
* Wraps a ConnectableObservable and calls its connect() method once
Expand All @@ -47,7 +49,7 @@ public OnSubscribeAutoConnect(ConnectableObservable<? extends T> source,
}
@Override
public void call(Subscriber<? super T> child) {
source.unsafeSubscribe(child);
source.unsafeSubscribe(Subscribers.wrap(child));
if (clients.incrementAndGet() == numberOfSubscribers) {
source.connect(connection);
}
Expand Down

0 comments on commit 29b9de2

Please sign in to comment.