Skip to content

Instantly share code, notes, and snippets.

@NsAveek
Last active November 1, 2019 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NsAveek/415b83933176099deb6da7a799a1aa15 to your computer and use it in GitHub Desktop.
Save NsAveek/415b83933176099deb6da7a799a1aa15 to your computer and use it in GitHub Desktop.
/** Represents Module for Test Management
* @author Aveek
* @author www.myproject.com
* @version 1
* @since 4.4.0 - Version
*/
@Module
internal class TestModule (val context : TestManagement) {
/**
* provides viewModel of the XML
* @param repository is containing the Repository instance which we need to call api from viewmodel
* @return Instance of ViewModel
*
* Since ViewModelProviders only accepts non-zero argument as parameter
* we had to make a Factory method to override the default behavior and accepts repository as @param
*/
@Provides
@ActivityScope
fun viewModel(repository: CustomRepository): TestManagementVM = ViewModelProviders.of(context, TestManagementVMFactory(repository)).get(TestManagementVM::class.java)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment