How to use BroadcastReceiver in MVVM architecture in Android?

2.8k views Asked by At

I can think of 2 options but neither of them sounds best-practice :

  1. Extending LiveData. But then it would hold a reference to Context, and as Google states this is a very bad design to hold any reference to Views or Context inside ViewModel.

  2. Extending LifecycleObserver, like this : https://stackoverflow.com/a/44449738

What is the recommended and right way of using broadcast in MVVM ?

0

There are 0 answers