Last active
August 10, 2020 16:17
-
-
Save catalinghita8/965f86d915097b12343c4c779c724eef to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| interface DataSource { | |
| fun getCachedData(): String | |
| } | |
| class LocalDataClient: DataSource { | |
| private val jsonFile = resources.getFile(JSON_FILE_TAG) | |
| override fun getCachedData() = jsonFile.toString() | |
| } | |
| class DataViewModel(private val dataClient: DataSource) { | |
| fun getCachedData() = dataClient.getCachedData() | |
| } | |
| // Container of objects shared across the whole project | |
| class DependencyInjector { | |
| val localDataClient: DataSource = LocalDataClient() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment