ObservableWatchData
open class ObservableWatchData<T : Any>
kotlin.Any | |
↳ | androidx.wear.watchface.ObservableWatchData |
An observable UI thread only data holder class (see Observer).
Summary
Public methods | |
---|---|
Unit |
addObserver(observer: Observer<T>) Adds the given Observer to the observers list. |
T |
getValueOr(default: T) Returns the value contained within this ObservableWatchData or default if there isn't one. |
Boolean |
hasValue() Whether or not this ObservableWatchData contains a value. |
Unit |
removeObserver(observer: Observer<T>) Removes an observer previously added by addObserver. |
open String |
toString() |
Properties | |
---|---|
open T |
The observable value. |
Public methods
addObserver
@UiThread fun addObserver(observer: Observer<T>): Unit
Adds the given Observer to the observers list. If hasValue would return true then Observer.onChanged will be called. Subsequently Observer.onChanged will also be called any time value changes. All of these callbacks are assumed to occur on the UI thread.
getValueOr
@UiThread fun getValueOr(default: T): T
Returns the value contained within this ObservableWatchData or default if there isn't one.
hasValue
@UiThread fun hasValue(): Boolean
Whether or not this ObservableWatchData contains a value.
removeObserver
@UiThread fun removeObserver(observer: Observer<T>): Unit
Removes an observer previously added by addObserver.
toString
open fun toString(): String
Properties
value
open var value: T
The observable value.