_uiState.postValue(UiState.Loading) when (val result = fetchTitleUseCase.execute(titleId)) { is Result.Success -> { _uiState.postValue(UiState.Loaded) _data.postValue(result.data) } is Result.Failure -> { when (val e = result.error) { is TopError.NetworkError -> _uiState.postValue(UiState.Retry) is TopError.TopClientError -> { _uiState.postValue(UiState.Error) showPopupAction.postValue(Event(e.popup)) } else -> showErrorCommand.postValue(e) } } } } } ๏ ViewModelScopeでJob のキャンセルをVMのライフサ イクルに紐づけることで非同 期処理の管理が楽に