ObserverType

public protocol ObserverType

Supports push-style iteration over an observable sequence.

  • E

    The type of elements in sequence that observer can observe.

    Declaration

    Swift

    associatedtype E
  • Notify observer about sequence event.

    Declaration

    Swift

    func on(_ event: Event<E>)

    Parameters

    event

    Event that occurred.

  • asObserver() Extension method

    Erases type of observer and returns canonical observer.

    Declaration

    Swift

    public func asObserver() -> AnyObserver<E>

    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<R>(_ transform: @escaping (R) throws -> E) -> AnyObserver<R>

    Return Value

    observer that transforms events.

  • onNext(_:) Extension method

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

    Declaration

    Swift

    public func onNext(_ element: E)

    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)