Skip to content

Instantly share code, notes, and snippets.

@mwrites
Last active September 14, 2017 13:52
Show Gist options
  • Save mwrites/f84c67c8e68946cd3f793bdf393f3a1e to your computer and use it in GitHub Desktop.
Save mwrites/f84c67c8e68946cd3f793bdf393f3a1e to your computer and use it in GitHub Desktop.
JobQueueCenter Dummy upload service
class DocumentUploadService : NSObject {
var document: Data
init(document: Data) {
self.document = document
super.init()
}
func execute(complete: @escaping (Bool)->Void) {
//do something with the document argument
print(document)
//our long fake networking method
DispatchQueue(label: "networking").asyncAfter(deadline: .now() + 5) {
DispatchQueue.main.async {
//let's say it only succeed after the second time to simulate unstable network
if self.retryableCount == 1 {
complete(true)
} else {
complete(false)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment