Skip to content

Instantly share code, notes, and snippets.

@barbeau
Created May 24, 2021 18:37
Show Gist options
  • Save barbeau/efec0f0b20cbdf10d18630014c3c1d42 to your computer and use it in GitHub Desktop.
Save barbeau/efec0f0b20cbdf10d18630014c3c1d42 to your computer and use it in GitHub Desktop.
Medium article - Room + Flow for location updates
class LocationRepository @Inject constructor(
private val locationDao: LocationDao
) {
fun getLocations() = locationDao.getLocations()
// By default Room runs suspend queries off the main thread, therefore, we don't need to
// implement anything else to ensure we're not doing long running database work
// off the main thread.
@Suppress("RedundantSuspendModifier")
@WorkerThread
suspend fun updateLocation(location: Location) {
locationDao.updateLocation(location)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment