We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c57274f commit ec77f40Copy full SHA for ec77f40
lite/src/main/java/com/pengxh/kt/lite/extensions/ViewModel.kt
@@ -14,18 +14,16 @@ import kotlinx.coroutines.launch
14
*/
15
fun ViewModel.launch(
16
block: suspend CoroutineScope.() -> Unit,
17
- onError: (e: Throwable) -> Unit = {},
+ onError: (Throwable) -> Unit = {},
18
onComplete: () -> Unit = {}
19
) {
20
viewModelScope.launch(
21
CoroutineExceptionHandler { _, throwable ->
22
- run {
23
- onError(throwable)
24
- }
+ onError(throwable)
25
}
26
27
try {
28
- block.invoke(this)
+ block()
29
} finally {
30
onComplete()
31
0 commit comments