addObserver
//causallabs-android/io.causallabs.android/CausalClient/addObserver
addObserver
[io.causallabs.android]\ fun <FeatureRequestT : FeatureRequest<, >> addObserver(request: FeatureRequestT, handler: () -> Unit): ObserverToken
Add an observer for the feature. The handler callback will be triggered if a Server Sent Event (SSE) forces this feature's values to change. It is recommended to use the compiler generated FeatureViewModels as those will wire up QA observers automatically and send impression events at the correct time.
Warning: Be sure to call the removeObserver method when observations are no longer required to prevent memory leaks.
Return
An ObserverToken which can be used to remove the observer using removeObserver.
Parameters
io.causallabs.android
request | the feature to monitor for SSE related updates. |
handler | the callback which will be called then the feature is updated by a Server Sent Event. |