Animesh Sahu
02/26/2020, 2:21 PMval handler = CoroutineExceptionHandler { context, exception ->
Log.d("exception", exception.message ?: "", exception)
suspensionFunc() // <--- This part, such as for calling a network requests.
}
What i thought of are:
1. Wrap the context with a CoroutineScope() and then launch with it.
2. Call using runBlocking{}, but isn't best idea cause it could affect app performance specially if ran on Main threads
3. Use GlobalScope()
4. Use GlobalScope() but launch to IO dispatcher.Evan R.
02/26/2020, 2:31 PMAnimesh Sahu
02/26/2020, 2:33 PMEvan R.
02/26/2020, 2:39 PMAnimesh Sahu
02/26/2020, 2:42 PMEvan R.
02/26/2020, 2:52 PMasCoroutineDispatcher(). Just define it around the same place you define the CEH and then inside the CEH you should be able to do:
val handler = CoroutineExceptionHandler { context, exception ->
// do your logging...
coroutineScopeYouDefined.launch { suspensionFunc() }
}Animesh Sahu
02/26/2020, 3:01 PMEvan R.
02/26/2020, 3:01 PMEvan R.
02/26/2020, 3:02 PMAnimesh Sahu
02/26/2020, 3:02 PM