Skip to content

Fix Constructor Injection in ViewModel

Compare
Choose a tag to compare
@Yazan98 Yazan98 released this 30 Sep 06:30
· 11 commits to master since this release

Fix ViewModel Type : (VaniteCoroutineViewModel)
From Init Block to Call initViewModel Method in init Block inside Sub ViewModels

This Change is a fix for Hilt Constructor Injection when Add UseCases Provided in Constructor

New Version

dependencies {
   implementation 'com.yazantarifi:Vanite:1.0.2'
   implementation 'com.yazantarifi:Vanite-data:1.0.2'
   implementation 'com.yazantarifi:Vanite-utils:1.0.2'
   implementation 'com.yazantarifi:Vanite-ui-binding:1.0.2'
   implementation 'com.yazantarifi:Vanite-ui:1.0.2'
   implementation 'com.yazantarifi:Vanite-prefs:1.0.2'
   implementation 'com.yazantarifi:Vanite-permissions:1.0.2'
   implementation 'com.yazantarifi:Vanite-log:1.0.2'
   implementation 'com.yazantarifi:Vanite-firebase:1.0.2'
}

Usage

@OptIn(ObsoleteCoroutinesApi::class)
@HiltViewModel
open class AuthViewModel @Inject constructor(
    private val getLoginUseCase: LoginUseCase,
    private val getRegisterUseCase: RegisterUseCase,
    private val getVerificationUseCase: AccountVerificationUseCase
) : VaniteCoroutineUseCasesViewModel() {

    init {
        initViewModel()
   }
}