Created
September 29, 2021 08:46
-
-
Save AlirezaNezami96/f16b89fe00eaffe92657ca11f1e1be95 to your computer and use it in GitHub Desktop.
This class provides the dependencies that classes want to function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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