Created
December 15, 2021 16:55
-
-
Save rmirabelli/33084ebb8489deb04cf8ba1ac1203272 to your computer and use it in GitHub Desktop.
A sample using a closure for asynchronous tasks
This file contains 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
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