fix(#21): move DB I/O to Dispatchers.IO in AddEdit screen models #22
Reference in New Issue
Block a user
Delete Branch "feat/21-move-db-io-to-dispatchers-io"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
withContext(Dispatchers.IO)inAddEditExpenseScreenModelandAddEditRecurringScreenModelso DB I/O no longer runs onDispatchers.Main.Test plan
./gradlew assembleDebugsucceedsCloses #21
Wrap getExpenses.awaitOne, upsertExpense.await, getRecurringExpenses.awaitOne and upsertRecurringExpense.await in withContext(Dispatchers.IO) { ... } so the suspending Room calls run off the main thread. State-flow updates stay inside screenModelScope.launch, which is Main-bound, and execute after the withContext block returns.