Skip to content

Instantly share code, notes, and snippets.

@stleamist
Created November 24, 2020 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stleamist/957630fcaab7120e7665aa6616f3f9d8 to your computer and use it in GitHub Desktop.
Save stleamist/957630fcaab7120e7665aa6616f3f9d8 to your computer and use it in GitHub Desktop.
import Combine
public extension Publisher {
func flatMap<P: Publisher>(
_ transformPublisher: @escaping (Self.Output) -> P,
mapError transformError: @escaping (Self.Failure) -> P.Failure
) -> Publishers.FlatMap<P, Publishers.MapError<Self, P.Failure>> {
return self.mapError(transformError).flatMap(transformPublisher)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment