SyncQueue 0.5

SyncQueue 0.5

测试已测试
语言语言 SwiftSwift
许可 MIT
发布日期上次发布2017年10月
SwiftSwift 版本3.0
SPM支持 SPM

Nick Romano 维护。



  • 作者:
  • Nick Romano

SyncQueue

当将模型更改同步到服务器时,有时需要按顺序并且逐个执行这些操作(参见 Trello 同步更改)。SyncQueueOperationQueue 上添加了一个轻薄的封装以逐个执行这些操作。

使用说明

将一个 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)