ObservableProtocol

public protocol ObservableProtocol : Bindable

Represents an observable sequence of events

  • The type of element in sequence.

    Declaration

    Swift

    associatedtype Element
  • asObservable Default implementation

    Provides an observable sequence of a concrete object.

    Default Implementation

    Type erasure for any observable implementing the protocol to a general Observable (same concept as AnyObject)

    Declaration

    Swift

    var asObservable: Observable<Element> { get }
  • Subscribes to an observable sequence events.

    Declaration

    Swift

    func subscribe<O>(_ observer: O) -> Cancelable where O : ObserverProtocol, Self.Element == O.Element

    Parameters

    observer

    An observer reacting to events of the sequence.

    Return Value

    Subscription object that can be used to cancel the observing.

  • create(with:) Default implementation

    Creates a concrete observable instance from the observable protocol.

    Default Implementation

    Declaration

    Swift

    static func create(with subscriptionHandler: @escaping SubscriptionHandler<Element>) -> Observable<Element>

    Parameters

    subscriptionHandler

    The subscription handler to be used on new subscriptions.

    Return Value

    Returns a new concreate observable instance using the provided subscription handler.