BJNObservable
public class BJNObservable<T>
BJNObservable
is a generic type that generates a callback when its value is changed.
It can be used to listen in on changes to a specific value, but not to update the value itself.
BJNObservable
is read-only, for write capabilities, see BJNMutableObservable
Monitor any change to the value as:
clientMuteState.onChange {
print("the client is now \(clientMuteState.value ? "muted" : "unmuted")")
}
-
Represents the value of this BJNObservable. Read only.
Declaration
Swift
public var value: T { get }
-
Register a callback to be executed when the value of this
BJNObservable
changes.Declaration
Swift
public func onChange(handler: @escaping () -> Void)
Parameters
handler
Note, this callback takes no parameters.