Swift Combine publisher won’t trigger in flatMap after finished event [duplicate]

The pattern to not terminate a pipeline on error is to capture the error with a flatMap:

changeSubject
   .flatMap {
      networkPublisher
         .catch { _ in Empty() }
   }
   .sink {
      print("Value: \($0)")
   }
   .store(in: &bag)

As you can see, .sink only receives an Output of String and an Error of Never, because the error is handled fully inside .flatMap

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top