PublishSubject
public final class PublishSubject<Element>
: Observable<Element>
, SubjectType
, Cancelable
, ObserverType
, SynchronizedUnsubscribeType
Represents an object that is both an observable sequence as well as an observer.
Each notification is broadcasted to all subscribed observers.
-
Undocumented
Declaration
Swift
public typealias SubjectObserverType = PublishSubject<Element>
-
Indicates whether the subject has any observers
Declaration
Swift
public var hasObservers: Bool { get }
-
Indicates whether the subject has been isDisposed.
Declaration
Swift
public var isDisposed: Bool { get }
-
Creates a subject.
Declaration
Swift
public override init()
-
Notifies all subscribed observers about next event.
Declaration
Swift
public func on(_ event: Event<Element>)
Parameters
event
Event to send to the observers.
-
Subscribes an observer to the subject.
Declaration
Swift
public override func subscribe<Observer>(_ observer: Observer) -> Disposable where Element == Observer.Element, Observer : 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() -> PublishSubject<Element>
-
Unsubscribe all observers and release resources.
Declaration
Swift
public func dispose()