Sudhir Singh Khanger
03/04/2021, 3:37 PM``` CoroutineScope(coroutineContext).launch {
val saveProfileWork = OneTimeWorkRequestBuilder<SaveProfileWorker>()
.setInputData(
workDataOf(
"IMAGE_URI" to "http://..."
)
)
.build()
val request = WorkManager.getInstance(context).beginWith(saveProfileWork).enqueue().await()
// post success
return@launch
}
```
1. As far as my understanding goes launch starts a coroutine and await() awaits the result from another builder aynch(). This means I will be creating a coroutine inside a coroutine. Outer would be part of my network layer and inner one would be work manager's. I am not sure what should be done here. This also sounds like I might have issue handling exception.
2. How do I get success value from await call? If it asynchronous then return will end the outer launch coroutine.Valtteri Puonti
03/05/2021, 4:23 AMSudhir Singh Khanger
03/05/2021, 7:20 AM