Skip to content

Instantly share code, notes, and snippets.

@AndreyPanov
Last active May 10, 2017 11:01
Show Gist options
  • Save AndreyPanov/9c1045b20b10274523a36144d4765264 to your computer and use it in GitHub Desktop.
Save AndreyPanov/9c1045b20b10274523a36144d4765264 to your computer and use it in GitHub Desktop.
final class Repository {
private let dataProdider: DataProvider
init(dataProdider: DataProvider = .init()) {
self.dataProdider = dataProdider
}
func getItem(onSuccess: @escaping (Item)->(), onError: @escaping (Error)->()) {
//background async request
dataProvider.request.items { [weak self] data, error in
if let item = ItemBuilder(with: data) {
onSuccess(item)
} else {
onError(error)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment