ObservableWatchData

public class ObservableWatchData<T extends Object>


An observable UI thread only data holder class (see Observer).

Parameters
<T extends Object>

The type of data held by this instance.

Summary

Nested types

ObservableWatchData.MutableObservableWatchData

ObservableWatchData which publicly exposes setValue(T) method.

Public fields

@NonNull T

The observable value.

Public methods

final @UiThread void

Adds the given Observer to the observers list.

final @UiThread @NonNull T
getValueOr(@NonNull T default)

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

final @UiThread boolean

Whether or not this ObservableWatchData contains a value.

final @UiThread void

Removes an observer previously added by addObserver.

@NonNull String

Public fields

value

@NonNull
public @NonNullvalue

The observable value.

Public methods

addObserver

@UiThread
@NonNull
public final @UiThread void addObserver(@NonNull Observer<@NonNull T> observer)

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
@NonNull
public final @UiThreadgetValueOr(@NonNull T default)

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

hasValue

@UiThread
@NonNull
public final @UiThread boolean hasValue()

Whether or not this ObservableWatchData contains a value.

removeObserver

@UiThread
@NonNull
public final @UiThread void removeObserver(@NonNull Observer<@NonNull T> observer)

Removes an observer previously added by addObserver.

toString

@NonNull
public String toString()