AsyncSubject

public final class AsyncSubject<Element>
    : Observable<Element>
    , SubjectType
    , ObserverType
    , SynchronizedUnsubscribeType

An AsyncSubject emits the last value (and only the last value) emitted by the source Observable, and only after that source Observable completes.

(If the source Observable does not emit any values, the AsyncSubject also completes without emitting any values.)

  • Declaration

    Swift

    public typealias SubjectObserverType = AsyncSubject<Element>
  • Indicates whether the subject has any observers

    Declaration

    Swift

    public var hasObservers: Bool { get }
  • Creates a subject.

    Declaration

    Swift

    public override init()
  • Notifies all subscribed observers about next event.

    Declaration

    Swift

    public func on(_ event: Event<E>)

    Parameters

    event

    Event to send to the observers.

  • Subscribes an observer to the subject.

    Declaration

    Swift

    public override func subscribe<O>(_ observer: O) -> Disposable where Element == O.E, O : ObserverType

    Parameters

    observer

    Observer to subscribe to the subject.

    Return Value

    Disposable object that can be used to unsubscribe the observer from the subject.

  • Returns observer interface for subject.

    Declaration

    Swift

    public func asObserver() -> AsyncSubject<Element>