- Notifications
You must be signed in to change notification settings - Fork21
Just a tiny library to make using GCD easier and intuitive
License
JARMourato/Dispatch
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Branch | Status |
---|---|
master | |
develop |
Dispatch requires swift 3.0. Use version 1.0.0 for swift 2.3 or version 0.9.8 for swift 2.2.
Dispatch is available throughCocoaPods. To installit, simply add the following line to your Podfile:
pod'Dispatch'
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage withHomebrew using the following command:
$ brew update$ brew install carthage
To integrate Dispatch into your Xcode project using Carthage, specify it in yourCartfile
:
github "Swiftification/Dispatch"
Runcarthage update
to fetch the Dispatch library and drag into your Xcode project.
And then simply
import DispatchFramework
And your good to go!
- Download and drop
Dispatch.swift
anywhere you like in your project. - That's it.
Dispatch.async(dispatch_get_main_queue()){ //Code to be run on the main thread}
Dispatch.async(Queue.main){ //Code to be run on the main thread}
Dispatch.async{ //Code to be run on the main thread}
Dispatch.async(Queue.main){ //Code to be run on the main thread}
letsomeCustomQueue=dispatch_queue_create("custom.queue.dispatch", DISPATCH_QUEUE_CONCURRENT)Dispatch.sync(someCustomQueue){ //Code to be synchronously on someCustomQueue}
Dispatch.after(1.0, queue:Queue.main){ //Code to be run on the main thread after 1 second}
Dispatch.after(1.0){ //Code to be run on the main thread after 1 second}
lettoken:dispatch_once_tDispatch.once(&token){ //Code to be run only once in App lifetime}
letmainQueue=Queue.main
letcustomConcurrentQueue=Queue.custom("custom.concurrent.queue.dispatch",Queue.Atribute.concurrent)letcustomSerialQueue=Queue.custom("custom.serial.queue.dispatch",Queue.Atribute.serial)
letpriority=0 // or you use one of the Global priorities (ex: Queue.Priority.UserInteractive)letglobalQueue=Queue.global(priority)// For comodity there are helpers for getting the Global queuesletglobalUserInteractiveQueue=Queue.globalUserInteractiveletglobalUserInitiatedQueue=Queue.globalUserInitiatedletglobalUtilityQueue=Queue.globalUtilityletglobalBackgroundQueue=Queue.globalBackground
- Carthage compatible
- Chainable methods
- Travis CI
- Unit Tests
- More examples
- If youfind a bug, open an issue.
- If youhave a feature request, open an issue.
- If youwant to contribute, submit a pull request.
João Mourato,joao.armourato@gmail.com
Gabriel Peart
Dispatch is available under the MIT license. See the LICENSE file for more info.
About
Just a tiny library to make using GCD easier and intuitive