Skip to content

Commit

Permalink
[FEAT/#17] Factory 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
MoonsuKang committed Jun 7, 2024
1 parent 6b94cf8 commit abc4d85
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.sopt.now.compose.screen.auth.signup

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.sopt.now.compose.repository.SignUpRepository

class SignUpViewModelFactory(private val signUpRepository: SignUpRepository) : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
if (modelClass.isAssignableFrom(SignUpViewModel::class.java)) {
@Suppress("UNCHECKED_CAST")
return SignUpViewModel(signUpRepository) as T
}
throw IllegalArgumentException("알 수 없는 ViewModel 클래스")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.sopt.now.compose.screen.main.mypage

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.sopt.now.compose.repository.UserInfoRepository

class MyPageViewModelFactory(private val userInfoRepository: UserInfoRepository) : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
if (modelClass.isAssignableFrom(MyPageViewModel::class.java)) {
@Suppress("UNCHECKED_CAST")
return MyPageViewModel(userInfoRepository) as T
}
throw IllegalArgumentException("알 수 없는 ViewModel 클래스")
}
}

0 comments on commit abc4d85

Please sign in to comment.