ObserverType

public protocol ObserverType

Supports push-style iteration over an observable sequence.

  • The type of elements in sequence that observer can observe.

    Declaration

    Swift

    associatedtype Element
  • Notify observer about sequence event.

    Declaration

    Swift

    func on(_ event: Event<Element>)

    Parameters

    event

    Event that occurred.

  • asObserver() Extension method

    Erases type of observer and returns canonical observer.

    Declaration

    Swift

    public func asObserver() -> AnyObserver<Element>

    Return Value

    type erased observer.

  • mapObserver(_:) Extension method

    Transforms observer of type R to type E using custom transform method. Each event sent to result observer is transformed and sent to self.

    Declaration

    Swift

    public func mapObserver<Result>(_ transform: @escaping (Result) throws -> Element) -> AnyObserver<Result>

    Return Value

    observer that transforms events.

  • onNext(_:) Extension method

    Convenience method equivalent to on(.next(element: Element))

    Declaration

    Swift

    public func onNext(_ element: Element)

    Parameters

    element

    Next element to send to observer(s)

  • onCompleted() Extension method

    Convenience method equivalent to on(.completed)

    Declaration

    Swift

    public func onCompleted()
  • onError(_:) Extension method

    Convenience method equivalent to on(.error(Swift.Error))

    Declaration

    Swift

    public func onError(_ error: Swift.Error)

    Parameters

    error

    Swift.Error to send to observer(s)