chamber / com.skydoves.chamber / ChamberField

ChamberField

class ChamberField<T> : LifecycleObserver

ChamberField is an interactive class to the internal Chamber data holder (ChamberStore) and a lifecycleObserver that can be observable. It should be used with com.skydoves.chamber.annotation.ShareProperty annotation that has a key name.

If we want to use the same synchronized value on the same custom scope and different classes, we should use the same key.

Constructors

<init>

ChamberField(value: T)

ChamberField is an interactive class to the internal Chamber data holder (ChamberStore) and a lifecycleObserver that can be observable. It should be used with com.skydoves.chamber.annotation.ShareProperty annotation that has a key name.

Properties

annotation

lateinit var annotation: Annotation

initialized

var initialized: Boolean

key

lateinit var key: String

value

var value: T

Functions

observe

fun observe(observer: ChamberFieldObserver<T>): Unit

sets ChamberFieldObserver to observe value data change.

fun observe(block: (t: T) -> Unit): Unit

sets ChamberFieldObserver to observe value data change using block.

onResume

fun onResume(): Unit

when lifecycle state is onResume, the value value will be updated from local storage.

postValue

fun postValue(value: T): Unit

sets value on the worker thread and post the value to the main thread.