From 57a902a1b4f7aeafcb7b5cfec0c15635d0fd2b63 Mon Sep 17 00:00:00 2001 From: Srdan Rasic Date: Fri, 24 Mar 2023 14:54:47 +0100 Subject: [PATCH] Fix append operator disposing race condition --- Sources/SignalProtocol+Combining.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/SignalProtocol+Combining.swift b/Sources/SignalProtocol+Combining.swift index 086c42c..62a5a01 100644 --- a/Sources/SignalProtocol+Combining.swift +++ b/Sources/SignalProtocol+Combining.swift @@ -143,18 +143,18 @@ extension SignalProtocol { /// Check out interactive example at [https://rxmarbles.com/#concat](https://rxmarbles.com/#concat) public func append(_ other: O) -> Signal 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 } }