Operator 0.1.4

Operator 0.1.4

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jun 2016
SPMSupports SPM

Maintained by Grant Oladipo.



Operator 0.1.4

Operator - Succinct Concurrent Code in Swift

Operator is a wrapper for Grand Central Dispatch written in Swift.

Requirements

  • iOS 9.0+
  • Xcode 7.3+

Communication

  • If you need help, DM @kocodude
  • If you’d like to ask a general question, for now open an issue.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Installation

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

pod "Operator"

Usage

Operator’s default context model uses the main queue when invoked on the main thread and the global queue when invoked anywhere else. Operator supports contexts in line with the available global queues:

  • Main
  • High Priority
  • Default Priority
  • Low Priority
  • Background

Operator supports the creation of serial and concurrent queues by passing a name with the enums:

  • Concurrent(“concurrent.queue.name”)
  • Serial(“serial.queue.name”)

async

Operator.async {
    print("Execute asynchronously")
}

which is the same as:

Operator.async(.DefaultContextModel) {
    print("Execute asynchronously")
}

To use a different context:

Operator.async(.Background) {
    print("Execute in the background")
}

delay

Operator.delay(forSeconds: 10.0) {
    print("Execute this 10 seconds later")
}
let customConcurrentContext = Context.Concurrent("com.myapp.mynewconcurrentqueue")
Operator.delay(forSeconds: 10.0, customConcurrentContext) {
    print("Execute this 10 seconds later")
}

sync

Operator.sync {
    print("Execute this 10 seconds later")
}
Operator.sync(.High) {
    print("Execute this 10 seconds later")
}

tick

Operator.tick {
    print("Execute this 10 seconds later")
}

Author

Grant Oladipo

e: [email protected]

t: @kocodude

License

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