ObservableProperty
public class ObservableProperty<ValueType>
A basic implementation of a property whose value can be observed
using callbacks.
Example:
var property = ObservableProperty(1)
property.subscribe { newValue in
print("newValue: \(newValue)")
}
property.value = 2
// Executing the above code prints:
// "newValue: 2"
-
The type of the callback to be called when the
valuechanges.Declaration
Swift
public typealias CallbackType = (ValueType -> ()) -
The
valuestored in this instance. Setting it to a new value will notify any subscriptions registered through thesubscribemethod.Declaration
Swift
public var value: ValueType -
Declaration
Swift
public init(_ value: ValueType)Parameters
valueThe initial value to store.
-
Register a subscriber that will be called with the new value when the
valuechanges.Declaration
Swift
public func subscribe(callback: CallbackType)Parameters
callbackThe function to call when the value changes.
View on GitHub
ObservableProperty Class Reference