I have two Activities, each one have its ViewModel, and I need to make the first Activity live data observer keep running when push to the new Activity, the current happening is when launch second Activity the observer stop working.
private fun observer() {
viewModel.myData.observe(this, {
when (it) {
it -> {
it.let {
val intent = Intent(Events.DATA_EVENT.value)
intent.putExtra("data", it)
LocalBroadcastManager.getInstance(this).sendBroadcast(intent)
}
}
}
})
}
How can I always observe the new data in first Activity?