TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Oct 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Nick Romano.
When syncing model changes to a server you sometimes need these to happen in order and one at a time (see Trello Syncing Changes). SyncQueue
adds a thin wrapper over OperationQueue
to perform these operations one at a time.
Add a SyncOperation
to the shared SyncQueue
.
import SyncQueue
let operation = SyncOperation { (currentOperation) in
Alamofire.request("https://httpbin.org/get").responseJSON { response in
if let json = response.result.value {
print("JSON: \(json)")
}
}.response { response in
// Let sync queue know the operation has completed
currentOperation.finishRunning()
}
}
SyncQueue.shared.queue.addOperation(operation)