Hey! Currently in MPP we are using SqlDelight and coroutines to insert data into db:
class DbHelper(db: Db) {
suspend fun insert(elements: List<Element>) = withContext(Dispatchers.Default) {
db.elementQueries.transaction {
db.elementQueries.insert(.....)
}
}
}
This works fine when elements list is not too big, but now we encountered use case where we need to insert larger amount of data (in worst case insert is
1200ms), and now this same approach is causing problems on iOS because this all happens on Main Thread(
async) , and while the data is inserting UI is getting blocked when user interacts with UI (scrolling).
Is there a way with current coroutines versions
"1.3.5-native-mt"
to improve this? afaik with current coroutines version it is not possible move insert to Background Thread?