Skip to content

Instantly share code, notes, and snippets.

@dimebt
Last active February 7, 2019 11:49
Show Gist options
  • Save dimebt/93b41e3f94c45b7233c50573f9f874b5 to your computer and use it in GitHub Desktop.
Save dimebt/93b41e3f94c45b7233c50573f9f874b5 to your computer and use it in GitHub Desktop.
let backgroundQueue = DispatchQueue.global(qos: .background)
firstly {
showLoader()
}.then(on: backgroundQueue) {
self.fetchJSON()
}.then(on: backgroundQueue) { (photos) in
self.downloadPhotos(photos: Array(photos.prefix(40)))
}.done(on: DispatchQueue.main, flags: nil) { _ in
self.hideLoader()
self.photoCollectionView.reloadData()
}.catch { (error) in
print(error.localizedDescription)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment