Skip to content

Instantly share code, notes, and snippets.

@OhhhThatVarun
Last active March 16, 2021 11:26
Show Gist options
  • Select an option

  • Save OhhhThatVarun/4eb40eb1e07e8fe4862f3c8e597814e5 to your computer and use it in GitHub Desktop.

Select an option

Save OhhhThatVarun/4eb40eb1e07e8fe4862f3c8e597814e5 to your computer and use it in GitHub Desktop.
SwDin: ViewModel inject example.
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