Abhimanyu
05/13/2024, 6:29 AMoverride fun setAlarm() {
CoroutineScope(
context = dispatcherProvider.io,
).launch {
// ...
val alarmManager = getAlarmManager() ?: return@launch
// ...
}
}
Error
Expression with labels increase complexity and affect maintainability. [LabeledExpression]
The idea is to return early if required, from inside the code blocks.Brais Gabin
05/13/2024, 7:29 AMlaunch
to another function so you just return
inside a regular function, etc. Any way that avoids the usage of labeled expressions. With that code I need to go up and read again to see what @launch
is. And what does is implies.ephemient
05/13/2024, 7:41 AMAbhimanyu
05/13/2024, 7:43 AMBroadcastReceiver()
.
Any suggestion for this?
creating a disconnected CoroutineScope like that is bad practice
ephemient
05/13/2024, 7:43 AMtaking care to cancel these coroutine scopes when they are no longer needed (see section on custom usage below for explanation and example)
ephemient
05/13/2024, 7:44 AMMainScope()
that is set up to be cancelled when your receiver is destroyed or similarAbhimanyu
05/13/2024, 7:45 AM