Variable

public class Variable<Element>

Variable is a wrapper for BehaviorSubject.

Unlike BehaviorSubject it can’t terminate with error, and when variable is deallocated it will complete it’s observable sequence (asObservable).

  • Gets or sets current value of variable.

    Whenever a new value is set, all the observers are notified of the change.

    Even if the newly set value is same as the old value, observers are still notified for change.

    Declaration

    Swift

    public var value: E
  • Initializes variable with initial value.

    Declaration

    Swift

    public init(_ value: Element)

    Parameters

    value

    Initial variable value.

  • Declaration

    Swift

    public func asObservable() -> Observable<E>

    Return Value

    Canonical interface for push style sequence