Created
May 24, 2021 18:37
-
-
Save barbeau/efec0f0b20cbdf10d18630014c3c1d42 to your computer and use it in GitHub Desktop.
Medium article - Room + Flow for location updates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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