Last active
March 16, 2021 11:26
-
-
Save OhhhThatVarun/4eb40eb1e07e8fe4862f3c8e597814e5 to your computer and use it in GitHub Desktop.
SwDin: ViewModel inject example.
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
| import SwDin | |
| final class HomeViewModel: SwDinViewModel { | |
| @Inject | |
| private let dbClient: DatabaseClient | |
| @Inject | |
| private let apiClient: ApiClient | |
| func onAttach() { | |
| // do additional setup | |
| } | |
| func requestData(): Data { | |
| if dbClient.hasData { | |
| return dbClient.requestData() | |
| } | |
| return apiClient.requestData() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment