Hey everyone, looking at the docs for CoroutineWor...
# coroutines
n
Hey everyone, looking at the docs for CoroutineWorker from WorkManager, I came across this
Copy code
class CoroutineDownloadWorker(
    context: Context,
    params: WorkerParameters
) : CoroutineWorker(context, params) {

    override suspend fun doWork(): Result {
        withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
            val data = downloadSynchronously("<https://www.google.com>")
            saveData(data)
            return Result.success()
        }
    }
}
Which wouldn't work? As it has to be
return@withContext
and you need a return value outside of it? Or I am I missing something
m
Move the return to before
withContext
🙂
Copy code
return withContext… {
   …
   Result.success()
}
n
Oh thank you