Getting an intuition around Publisher.makeConnectable

Hi! I’m trying to build an intuition for why Publisher.makeConnectable is only available when the failure type is Never. My initial instinct would be so that the underlying publisher isn’t completed before it’s connected to, but a Never failure type still allows ordinary pre-connect .finished events.

Any thoughts or considerations around the Never failure constraint would help—thanks! :pray:t4:

Yes. I don't see the rationale for this constraint either.
Hope someone with the knowledge could answer this question.

Publishers.MakeConnectable doesn't have the same constraint. Perhaps whoever implemented makeConnectable made a copy/paste error when adding the operator method.

You can add your own operator to work around the problem:

extension Publisher {
    public func makeConnectableWithAnyFailureType() -> Publishers.MakeConnectable<Self> {
        return .init(upstream: self)
    }
}
1 Like