docs/Classes/BehaviorSubject.html
public final class BehaviorSubject<Element>:
Observable<Element>,
SubjectType,
ObserverType,
SynchronizedUnsubscribeType,
Cancelable
Represents a value that changes over time.
Observers can subscribe to the subject to receive the last (or initial) value and all subsequent notifications.
`
SubjectObserverType
`
Undocumented
Swift
public typealias SubjectObserverType = BehaviorSubject<Element>
`
hasObservers
`
Indicates whether the subject has any observers
Swift
public var hasObservers: Bool { get }
`
isDisposed
`
Indicates whether the subject has been disposed.
Swift
public var isDisposed: Bool { get }
`
init(value:)
`
Initializes a new instance of the subject that caches its last value and starts with the specified value.
Swift
public init(value: Element)
| value |
Initial value sent to observers when no other value has been received by the subject yet.
|
`
value()
`
Gets the current value or throws an error.
Swift
public func value() throws -> Element
Latest value.
`
on(_:)
`
Notifies all subscribed observers about next event.
Swift
public func on(_ event: Event<Element>)
| event |
Event to send to the observers.
|
`
subscribe(_:)
`
Subscribes an observer to the subject.
Swift
override public func subscribe<Observer>(_ observer: Observer) -> Disposable where Element == Observer.Element, Observer : ObserverType
| observer |
Observer to subscribe to the subject.
|
Disposable object that can be used to unsubscribe the observer from the subject.
`
asObserver()
`
Returns observer interface for subject.
Swift
public func asObserver() -> BehaviorSubject<Element>
`
dispose()
`
Unsubscribe all observers and release resources.
Swift
public func dispose()