Latest 0.3
Homepage https://github.com/severehed/AsyncTimeoutOperationQueue
License MIT
Platforms ios 9.0, osx 10.10

CI Status
Version
License
Platform

Usage

Use as extension to regular queue

import AsyncTimeoutOperationQueue

let queue = OperationQueue()

  queue
      .addAsyncOperation { (completion) in
        //some async work here
        //don't forget to call completion when it's done!
        completion?()
      }
      .timeout(5)
      .onTimeout {
          //called only if operation cancelled by timeout
      }
      .onCompletionOrTimeout {
          //called in both cases: timeout or success finish
      }

If you want to set default timeout for all operations in this queue, simply create AsyncTimeoutOperationQueue

import AsyncTimeoutOperationQueue

let queue = AsyncTimeoutOperationQueue()
queue.defaultTimeout = 10

  queue
      .addAsyncOperation { (completion) in
        //some async work here
        //don't forget to call completion when it's done!
        completion?()
      }
      .timeout(5) //you still able to override default timeout
      .onTimeout {
          //called only if operation cancelled by timeout
      }
      .onCompletionOrTimeout {
          //called in both cases: timeout or success finish
      }

Also you can create AsyncBlockOperation itself or inherit it

import AsyncTimeoutOperationQueue

let operation =
            AsyncBlockOperation(block: { (completion) in
                completion?()
            },
            timeout: 30,
            onTimeout: {

            })

Requirements

Xcode 9+, swift 4.0,
No other special requirements 🍺

Installation

AsyncTimeoutOperationQueue is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'AsyncTimeoutOperationQueue'

Author

severehed

License

AsyncTimeoutOperationQueue is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "AsyncTimeoutOperationQueue",
    "version": "0.3",
    "summary": "Async NSOperation with timeouts",
    "description": "Async NSOperation with timeout, onTimeout and onCompletion calls",
    "homepage": "https://github.com/severehed/AsyncTimeoutOperationQueue",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": "severehed",
    "source": {
        "git": "https://github.com/severehed/AsyncTimeoutOperationQueue.git",
        "tag": "0.3"
    },
    "swift_version": "4.0",
    "platforms": {
        "ios": "9.0",
        "osx": "10.10"
    },
    "ios": {
        "frameworks": "Foundation"
    },
    "osx": {
        "frameworks": "Foundation"
    },
    "source_files": "AsyncTimeoutOperationQueue/Classes/**/*"
}

Pin It on Pinterest

Share This