Skip to content

Commit

Permalink
Fixed issue that sometimes happened where RxBleRadioOperationConnect …
Browse files Browse the repository at this point in the history
…was not yet subscribed while running. #94

Reviewers: michal.zielinski, pawel.urban

Reviewed By: pawel.urban

Differential Revision: https://phabricator.polidea.com/D1947
  • Loading branch information
dariuszseweryn committed Nov 10, 2016
1 parent a4fc0cc commit 4daaed1
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class RxBleRadioOperationConnect extends RxBleRadioOperation<BluetoothGat
private final Runnable releaseRadioRunnable = () -> releaseRadio();
private final Runnable emptyRunnable = () -> {
};
private final BehaviorSubject<Boolean> isSubscribed = BehaviorSubject.create(false);
private final BehaviorSubject<Boolean> isSubscribed = BehaviorSubject.create();
private final Observable<BluetoothGatt> operationConnectAsObservableWithSubscribersMonitoring = super.asObservable()
.doOnSubscribe(() -> isSubscribed.onNext(true))
.doOnUnsubscribe(() -> isSubscribed.onNext(false))
Expand Down Expand Up @@ -53,6 +53,7 @@ protected void protectedRun() {
// when there are no subscribers there is no point of continuing work -> next will be disconnect operation
.takeUntil(asObservableHasNoSubscribers().doOnNext(noSubscribers -> RxBleLog.d("No subscribers, finishing operation")))
.doOnCompleted(onConnectionEstablishedRunnable::run)
.doOnNext(ignored -> isSubscribed.onCompleted())
.subscribe(getSubscriber());
onConnectCalledRunnable.run();
}
Expand Down

0 comments on commit 4daaed1

Please sign in to comment.