PublisherType

public struct PublisherType<Element, ErrorType> where ErrorType : Error

Abstraction over publisher/observable/signal producer types from reactive frameworks. This abstraction uses concept similar to type-erasure or protocol witness pattern, wrapping the behaviour of concrete implementations and delegating to them once the wrapper funcions are called.

  • Undocumented

    Declaration

    Swift

    public let subscribe: (SubscriberType<Element, ErrorType>) -> SubscriptionType
  • Undocumented

    Declaration

    Swift

    public init(subscribe: @escaping (SubscriberType<Element, ErrorType>) -> SubscriptionType)
  • Transforms any publishers into a Unfailable publisher with the same element type. After calling this method, a publisher will be derived and it won’t emit failures or error. In case the upstream emits an error, a fatalError will be executed, so be careful when using this operator.

    Declaration

    Swift

    public func assertNoFailure() -> PublisherType<Element, Never>
  • Maps elements emitted by the upstream into a new element type, given by the transform function provided by you

    Declaration

    Swift

    public func map<NewElement>(_ transform: @escaping (Element) -> NewElement) -> PublisherType<NewElement, ErrorType>

    Parameters

    transform

    a function that transforms each element emitted by the upstream into a new element

    Return Value

    a derived publisher that emits values of the new type, by applying the transform function provided by you