Subscribable

public protocol Subscribable<Element>

A type that can be subscribed to by an Observer to receive elements and completion.

  • Undocumented

    Declaration

    Swift

    associatedtype Element
  • Subscribes an Observer to receive elements and completion.

    Declaration

    Swift

    @discardableResult
    func subscribe<O>(_ observer: O) -> any Disposable where O : Observer, Self.Element == O.Element

    Return Value

    A Disposable representing the subscription. Disposing it stops event delivery.

  • subscribe(_:onComplete:) Extension method

    Subscribe a callback to receive the Element.

    Declaration

    Swift

    @discardableResult
    func subscribe(_ onNext: @escaping (Element) -> Void, onComplete: @escaping () -> Void = { }) -> any Disposable

    Parameters

    onNext

    The callback called with the Element.

    onComplete

    The callback called once when the upstream source completes. Not invoked on external disposal.

    Return Value

    A Disposable that can be disposed to stop the observer from being called.