Skip to content

Instantly share code, notes, and snippets.

@rmirabelli
Created December 15, 2021 16:55
Show Gist options
  • Save rmirabelli/33084ebb8489deb04cf8ba1ac1203272 to your computer and use it in GitHub Desktop.
Save rmirabelli/33084ebb8489deb04cf8ba1ac1203272 to your computer and use it in GitHub Desktop.
A sample using a closure for asynchronous tasks
func useAsynchronousFetch() -> Void {
fetchData(value: 23) { result in
switch result {
case .success(let data):
transformData(data) { result in
switch result {
case .success(let viewModel):
displayModel(viewModel)
case .failure(let error):
displayError(error)
}
}
case .failure(let error):
displayError(error)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment