Skip to content

Commit

Permalink
[Feat/#63] viewModel init 넣기
Browse files Browse the repository at this point in the history
  • Loading branch information
ss99x2002 committed Jul 15, 2023
1 parent 6e00aa4 commit ae6a16c
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ import timber.log.Timber
class QuestionAnswerViewModel(private val questionAnswerRepositoryImpl: QuestionAnswerRepositoryImpl) :
ViewModel() {

init {
getQuestionAnswer()
}

private var _qnaResponse = MutableLiveData<QuestionAnswerResponseDto.QnaData>()
val qnaResponse: LiveData<QuestionAnswerResponseDto.QnaData> = _qnaResponse

var isMyAnswer = MutableLiveData<Boolean?>(false)
var isOpponentAnswer = MutableLiveData<Boolean?>(false)
var isMyAnswer = MutableLiveData(false)
var isOpponentAnswer = MutableLiveData(false)

fun getQuestionAnswer() {
private fun getQuestionAnswer() {
viewModelScope.launch {
questionAnswerRepositoryImpl.getQuestionAnswer()
.onSuccess { response ->
Expand All @@ -28,8 +32,8 @@ class QuestionAnswerViewModel(private val questionAnswerRepositoryImpl: Question
isMyAnswer.value = response.data.isMyAnswer
isOpponentAnswer.value = response.data.isOpponentAnswer
}.onFailure { error ->
Log.e("hyeon", "getQuestionAnswer 실패 " + error.message)
}
Log.e("hyeon", "getQuestionAnswer 실패 " + error.message)
}
}
}
}

0 comments on commit ae6a16c

Please sign in to comment.