Skip to content

Commit

Permalink
Fix crash caused by Observables that send a value synchronously while…
Browse files Browse the repository at this point in the history
… being subscribed to. Combine requires receiving the subscription event before receiving and value events.
  • Loading branch information
epatey authored and freak4pc committed Jun 26, 2019
1 parent 86d24d7 commit 82c35bc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Sources/Rx+Combine/Observable+Combine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ public extension ObservableConvertibleType {
/// so the Observable pushes events to the Publisher.
var publisher: AnyPublisher<Element, Swift.Error> {
AnyPublisher<Element, Swift.Error> { subscriber in
let disposable = SingleAssignmentDisposable()
subscriber.receive(
subscription: RxSubscription(disposable: self.asObservable()
.subscribe(subscriber.pushRxEvent))
subscription: RxSubscription(disposable: disposable)
)
disposable.setDisposable(self.asObservable()
.subscribe(subscriber.pushRxEvent))
}
}

Expand Down

0 comments on commit 82c35bc

Please sign in to comment.