understandingCombine icon indicating copy to clipboard operation
understandingCombine copied to clipboard

Retry

Open moreindirection opened this issue 4 years ago • 1 comments

https://github.com/mattneub/understandingCombine/blob/236c4af76689d71d985cd00bf64a1b726101ca35/operators/operatorsErrorHandlers/operatorsRetry.txt#L35

Couldn't this be achieved without share, by using a delayed Fail? For example:

URLSession.shared.dataTaskPublisher(for: url)
  .catch { error in
    Fail(error: error).delay(for: 0.5, scheduler: DispatchQueue.main)
        .eraseToAnyPublisher()
}
.retry(3)

moreindirection avatar Apr 25 '20 16:04 moreindirection

I prefer this solution.

I also believe that the use of share defeats the purpose of retry. Using share should result in only one subscription being sent to the DataTaskPublisher. Thus, only one network request is sent, even if it fails. Or is my understanding of share wrong?

s-k avatar May 12 '20 10:05 s-k