Skip to content

Create ViewModel

Adi Andrea edited this page Oct 15, 2024 · 2 revisions

ViewModel classes will be responsible to manage our business logic.

class AuthenticationViewModel
@Inject constructor(private val dataManager: DataManager) : BaseViewModel() {
    //your business logic here
}

Inject into dependency injection modules in ViewModelModule.kt file

@Module
abstract class ViewModelModule{

    @Binds
    @IntoMap
    @ViewModelKey(AuthenticationViewModel::class)
    abstract fun bindAuthenticationViewModel(authViewModel: AuthenticationViewModel): ViewModel

}
Clone this wiki locally