Skip to content

Commit

Permalink
Fix append operator disposing race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
srdanrasic committed Mar 24, 2023
1 parent dfb63f8 commit 57a902a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/SignalProtocol+Combining.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,18 @@ extension SignalProtocol {
/// Check out interactive example at [https://rxmarbles.com/#concat](https://rxmarbles.com/#concat)
public func append<O: SignalProtocol>(_ other: O) -> Signal<Element, Error> where O.Element == Element, O.Error == Error {
return Signal { observer in
let serialDisposable = SerialDisposable(otherDisposable: nil)
serialDisposable.otherDisposable = self.observe { event in
let disposable = CompositeDisposable()
disposable += self.observe { event in
switch event {
case .next(let element):
observer.receive(element)
case .failed(let error):
observer.receive(completion: .failure(error))
case .completed:
serialDisposable.otherDisposable = other.observe(with: observer.on)
disposable += other.observe(with: observer.on)
}
}
return serialDisposable
return disposable
}
}

Expand Down

0 comments on commit 57a902a

Please sign in to comment.