Google is committed to advancing racial equity for Black communities. See how.

ObservableWatchData

open class ObservableWatchData<T : Any>
kotlin.Any
   ↳ androidx.wear.watchface.ObservableWatchData

An observable UI thread only data holder class.

Summary

Protected constructors
<init>(_value: T?)

An observable UI thread only data holder class.

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

Whether or not this ObservableWatchData contains a value.

Unit
removeObserver(observer: Observer<T>)

Removes an observer previously added by addObserver.

Properties
open T

The observable value.

Protected constructors

<init>

protected ObservableWatchData(_value: T?)

An observable UI thread only data holder class.

Parameters

Public methods

addObserver

@UiThread fun addObserver(observer: Observer<T>): Unit

Adds the given observer to the observers list. The events are dispatched on the ui thread. If there's any data held within the ObservableWatchData it will be immediately delivered to the observer.

getValueOr

fun getValueOr(default: T): T

Returns the value contained within this ObservableWatchData or default if there isn't one.

hasValue

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.

Properties

value

open var value: T

The observable value.