Search in sources :

Example 1 with MainViewModel

use of com.mindorks.framework.mvvm.ui.main.MainViewModel in project android-mvvm-architecture by MindorksOpenSource.

the class ActivityModule method provideMainViewModel.

@Provides
MainViewModel provideMainViewModel(DataManager dataManager, SchedulerProvider schedulerProvider) {
    Supplier<MainViewModel> supplier = () -> new MainViewModel(dataManager, schedulerProvider);
    ViewModelProviderFactory<MainViewModel> factory = new ViewModelProviderFactory<>(MainViewModel.class, supplier);
    return new ViewModelProvider(activity, factory).get(MainViewModel.class);
}
Also used : ViewModelProviderFactory(com.mindorks.framework.mvvm.ViewModelProviderFactory) MainViewModel(com.mindorks.framework.mvvm.ui.main.MainViewModel) ViewModelProvider(androidx.lifecycle.ViewModelProvider) Provides(dagger.Provides)

Aggregations

ViewModelProvider (androidx.lifecycle.ViewModelProvider)1 ViewModelProviderFactory (com.mindorks.framework.mvvm.ViewModelProviderFactory)1 MainViewModel (com.mindorks.framework.mvvm.ui.main.MainViewModel)1 Provides (dagger.Provides)1