测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可 | MIT |
发布日期上次发布 | 2017年10月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 Nick Romano 维护。
当将模型更改同步到服务器时,有时需要按顺序并且逐个执行这些操作(参见 Trello 同步更改)。SyncQueue
在 OperationQueue
上添加了一个轻薄的封装以逐个执行这些操作。
将一个 SyncOperation
添加到共享的 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)