Publisher

public extension Publisher
  • Wrap a Publisher in a Future of type <Output, Never>

    Declaration

    Swift

    func asFuture() -> Future<Output, Never>
  • Wrap a Publisher in a Deferred Future of type <Output, Never>

    Declaration

    Swift

    func asDeferredFuture() -> Deferred<Future<Output, Never>>
  • Convert a publisher output into a swift Resultobject to make handling sink‘s easier

    Declaration

    Swift

    func convertToResult() -> AnyPublisher<Result<Output, Failure>, Never>
  • Call .handleEvents, but only use the receiveOutput callback as a shorthand way of running some logic or clean up code

    Declaration

    Swift

    func onReceiveOutput(_ callback: @escaping ((Self.Output) -> Void)) -> Publishers.HandleEvents<Self>
  • Custom sink implementation breaking each piece into a seperate dedicated callback, avoiding the need to call a switch or unwrap an error

    Declaration

    Swift

    func sink(onError: @escaping ((Failure) -> Void), onSuccess: @escaping ((Output) -> Void), onComplete: (() -> Void)? = nil) -> AnyCancellable