Are Room Database queries async? And if so, for lack of a better term, is something like this async/race condition safe?
fun insertThingAsync(thing: Thing) = async(Dispatchers.IO) {
try {
dao.deleteAllThings()
dao.insertThing(thing)
}
catch (e: Throwable) {
// Stuff
}
}
In other words, is it possible, in this case, for the dao to attempt to insert the thing before dao.deleteAllThings() completes, and therefore have the chance of deleting the newly inserted thing as well?
If so, what are ways you all handle things like this to make sure you do not try to insert until the delete is complete?
I'm also wondering about the same use case with roomDatabase.clearAllTables, because of conversations in this thread.