You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In chapter 7 "Create the Task Repository", and in the 2nd step of section "Save and refresh network data", the code block suggests we do
suspendfunrefresh() {
val networkTasks = networkDataSource.loadTasks()
localDataSource.deleteAll()
val localTasks = withContext(dispatcher) {
networkTasks.toLocal()
}
localDataSource.upsertAll(networkTasks.toLocal()) // THIS IS THE ERROR
}
as you can see, localTasks is pointless here because you are doing the same thing in the erroneous line but you are also blocking the main thread. Instead, it should look like this
suspendfunrefresh() {
val networkTasks = networkDataSource.loadTasks()
localDataSource.deleteAll()
val localTasks = withContext(dispatcher) {
networkTasks.toLocal()
}
localDataSource.upsertAll(localTasks) // CORRECTED LINE
}
The text was updated successfully, but these errors were encountered:
Mario-paul
changed the title
[Data layer codelab] Small error in code in Chapter 7
[Data layer codelab] Small error in 'refresh()' method in Chapter 7
Aug 18, 2023
In chapter 7 "Create the Task Repository", and in the 2nd step of section "Save and refresh network data", the code block suggests we do
as you can see, localTasks is pointless here because you are doing the same thing in the erroneous line but you are also blocking the main thread. Instead, it should look like this
The text was updated successfully, but these errors were encountered: