Coder Social home page Coder Social logo

queue's Introduction

Queue

Carthage compatible

a task queue with local persistent by Swift 2.0

#Overview

Queue is a subclass of NSOperationQueue so you get:

Serial or concurrent queues Task priority Multiple queues Dependencies Task persistence (via protocol) Retries (exponential back-off)

#Minimum iOS 8.0

#Motivation

With a good queuing solution you can provide a much better user experience in areas such as:

Web requests Saving/creating content (images, video, audio) Uploading data

The actual code to perform the task gets passed to the queue in the form of a taskHandler closure. Each QueueTask must have a taskType key which corresponds to a specific taskCallback.

#Example Code

For a thorough example see the demo project in the top level of the repository.

##Create a queue

let queue = Queue(queueName: "NetWorking", maxConcurrency: 1, maxRetries: 3, serializationProvider: NSUserDefaultsSerializer(),logProvider: ConsoleLogger())

##Create a task

queue.addTaskCallback("Create") { (task) -> Void in
    print("Create")
    task.complete(nil)
}
        
queue.addTaskCallback("Delete") { (task) -> Void in
    task.complete(nil)
}
        
queue.addTaskCallback("Update") { (task) -> Void in
            
}
        
queue.addTaskCallback("Select") { (task) -> Void in
            
}
        
let task = QueueTask(queue: queue, type: "Create", userInfo: nil, retries: 3)
let taskDelete = QueueTask(queue: queue, type: "Delete", userInfo: nil, retries: 3)
queue.addOperation(taskDelete)
queue.addOperation(task)

queue's People

Contributors

medisean avatar

Watchers

范英强 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.