Android - Access LiveData Repository in BroadcastReceiver or Service

Viewed 1094

Im using MVVM Pattern and my Repository uses LiveData. But I need to access the data from BroadcastReceiver or IntentService. LiveData doesn't work in BroadcastReceiver because of missing LiveCircle and I read it isn’t recommended in Services. Do I need to change my Repository to ReactiveX or what's the best practise in this case?

Repository:

object MainRepository : Repository {

    override fun getGeofences(context: Context): LiveData<List<GeofenceModel>>? {
        return GeofenceDatabase.getInstance(context.applicationContext)?.geofenceDao()?.getGeofences
    }

    override fun createGeofence(context: Context, geofenceModel: GeofenceModel) {
        GeofenceDatabase.getInstance(context.applicationContext)?.geofenceDao()?.createGeofence(geofenceModel)
    }
}
0 Answers
Related