Last active
May 10, 2017 11:01
-
-
Save AndreyPanov/9c1045b20b10274523a36144d4765264 to your computer and use it in GitHub Desktop.
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
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