Skip to content

Commit

Permalink
[fix] : ViewModelFactory 의존성 수동 주입
Browse files Browse the repository at this point in the history
  • Loading branch information
chanubc committed Jan 3, 2024
1 parent 480b245 commit 8c30b7f
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package org.sopt.dosopttemplate.utils
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import org.sopt.dosopttemplate.data.ApiFactory
import org.sopt.dosopttemplate.data.datasourceimpl.remote.AuthDataSourceImpl
import org.sopt.dosopttemplate.data.datasourceimpl.remote.ReqresDataSourceImpl
import org.sopt.dosopttemplate.data.repositoryimpl.AuthRepository
import org.sopt.dosopttemplate.data.repositoryimpl.AuthRepositoryImpl
import org.sopt.dosopttemplate.data.repositoryimpl.ReqresRepositoryImpl
import org.sopt.dosopttemplate.ui.doandroid.DoAndroidViewModel
import org.sopt.dosopttemplate.ui.login.AuthViewModel
Expand All @@ -16,12 +17,14 @@ class ViewModelFactory :
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return when {
modelClass.isAssignableFrom(AuthViewModel::class.java) -> {
val repository = AuthRepository(ApiFactory.ServicePool.authService)
val repository =
AuthRepositoryImpl(AuthDataSourceImpl(ApiFactory.ServicePool.authService))
AuthViewModel(repository) as T
}

modelClass.isAssignableFrom(SignUpViewModel::class.java) -> {
val repository = AuthRepository(ApiFactory.ServicePool.authService)
val repository =
AuthRepositoryImpl(AuthDataSourceImpl(ApiFactory.ServicePool.authService))
SignUpViewModel(repository) as T
}

Expand Down

0 comments on commit 8c30b7f

Please sign in to comment.