Combine: how to replace/catch an error without completing the original publisher?
问题 Given the following code: enum MyError: Error { case someError } myButton.publisher(for: .touchUpInside).tryMap({ _ in if Bool.random() { throw MyError.someError } else { return "we're in the else case" } }) .replaceError(with: "replaced Error") .sink(receiveCompletion: { (completed) in print(completed) }, receiveValue: { (sadf) in print(sadf) }).store(in: &cancellables) Whenever I tap the button, I get we're in the else case until Bool.random() is true - now an error is thrown. I tried