Skip to content

Instantly share code, notes, and snippets.

@joelmarquez90
Created January 3, 2018 03:46
Show Gist options
  • Save joelmarquez90/ee5cb203426e22bd64b3b6681600814a to your computer and use it in GitHub Desktop.
Save joelmarquez90/ee5cb203426e22bd64b3b6681600814a to your computer and use it in GitHub Desktop.
// Class definition. You're right, only ONE LINE of code!
class VersionViewModel: BaseViewModel<Version> {}
// Using it
let viewModel = VersionViewModel(provider: MoyaProvider<Service>())
viewModel.fetchData(service: .version(version: AppInfo.version())).startWithResult { result in
switch result {
case let .success(version):
// Handle version success response
case let .failure(error):
// Handle error
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment