CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

SyncQueue 0.5

SyncQueue 0.5

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Nick Romano.



  • By
  • Nick Romano

SyncQueue

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.

Usage

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)