Replies: 1 comment 3 replies
-
|
에러 핸들링 로직 abstract class BaseViewModel: ViewModel() {
protected val exceptionHandler = CoroutineExceptionHandler { _, throwable ->
val errorType =
if (throwable is CustomException) throwable.customError
else CustomErrorType.UN_KNOWN
viewModelScope.launch { onError(errorType) }
}
abstract suspend fun onError(errorType: CustomErrorType)
protected val viewModelScopeEH = viewModelScope + exceptionHandler
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
BaseViewModel
모든 Viewmodel에서 공통적으로 들어가야할게 뭐가 있을까요?
중복 코드를 피하기위해 BaseViewModel을 만들죠
Beta Was this translation helpful? Give feedback.
All reactions