Skip to content

Instantly share code, notes, and snippets.

@AlirezaNezami96
Created September 29, 2021 08:46
Show Gist options
  • Save AlirezaNezami96/f16b89fe00eaffe92657ca11f1e1be95 to your computer and use it in GitHub Desktop.
Save AlirezaNezami96/f16b89fe00eaffe92657ca11f1e1be95 to your computer and use it in GitHub Desktop.
This class provides the dependencies that classes want to function
object DependencyComponent {
fun inject(application: MyApplication) {
application.networkService = NetworkService(application, "SOME_API_KEY")
application.databaseService = DatabaseService(application, "dummy_db", 1)
}
fun inject(activity: MainActivity) {
val app = activity.application as MyApplication
activity.viewModel = MainViewModel(app.databaseService, app.networkService)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment