Just a tiny library to make using GCD easier and intuitive

Overview

Dispatch

## Build Status
Branch Status
master Bunch Status
develop Bunch Status

Dispatch

Swift 3.0 Platforms License

Carthage compatible Podspec

codebeat badge codecov

Note:

Dispatch requires swift 3.0. Use version 1.0.0 for swift 2.3 or version 0.9.8 for swift 2.2.

Installation

CocoaPods

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

pod 'Dispatch'

Carthage


Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Dispatch into your Xcode project using Carthage, specify it in your Cartfile:

github "Swiftification/Dispatch"

Run carthage update to fetch the Dispatch library and drag into your Xcode project.

And then simply

import DispatchFramework

And your good to go!

Manually

  1. Download and drop Dispatch.swift anywhere you like in your project.
  2. That's it.

Usage

Basic

Dispatch.async(dispatch_get_main_queue()) {
  //Code to be run on the main thread
}
Or using the helpers provided by Dispatch.Queue enum
Dispatch.async(Queue.main) {
  //Code to be run on the main thread
}
Or using the overloaded method to run on the main thread
Dispatch.async {
  //Code to be run on the main thread
}

Types of Dispatch

Async

Dispatch.async(Queue.main) {
  //Code to be run on the main thread
}

Sync

let someCustomQueue = dispatch_queue_create("custom.queue.dispatch", DISPATCH_QUEUE_CONCURRENT)
Dispatch.sync(someCustomQueue) {
  //Code to be synchronously on someCustomQueue
}

After

Dispatch.after(1.0, queue: Queue.main) {
  //Code to be run on the main thread after 1 second
}
Or using the overloaded method to run on the main thread
Dispatch.after(1.0) {
  //Code to be run on the main thread after 1 second
}

Once

let token : dispatch_once_t
Dispatch.once(&token) {
  //Code to be run only once in App lifetime
}

Queue Helpers

Main queue

let mainQueue = Queue.main 

Custom queue

let customConcurrentQueue = Queue.custom("custom.concurrent.queue.dispatch", Queue.Atribute.concurrent)
let customSerialQueue = Queue.custom("custom.serial.queue.dispatch", Queue.Atribute.serial)

Global queues

let priority = 0 // or you use one of the Global priorities (ex: Queue.Priority.UserInteractive)
let globalQueue = Queue.global(priority)

// For comodity there are helpers for getting the Global queues

let globalUserInteractiveQueue = Queue.globalUserInteractive
let globalUserInitiatedQueue = Queue.globalUserInitiated
let globalUtilityQueue = Queue.globalUtility
let globalBackgroundQueue = Queue.globalBackground

TODO

  • Carthage compatible
  • Chainable methods
  • Travis CI
  • Unit Tests
  • More examples

Communication

  • If you find a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Authors

License

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

You might also like...
A simple GCD based HTTP client and server, written in 'pure' Swift
A simple GCD based HTTP client and server, written in 'pure' Swift

SwiftyHTTP Note: I'm probably not going to update this any further - If you need a Swift networking toolset for the server side, consider: Macro.swift

GCDWebServer is a modern and lightweight GCD based HTTP 1.1 server designed to be embedded in iOS, macOS & tvOS apps.

GCDWebServer is a modern and lightweight GCD based HTTP 1.1 server designed to be embedded in iOS, macOS & tvOS apps. It was written from scr

MusicAlbumApp - Applications for training networking, field validation, screen transitions, and GCD

MusicAlbumApp This is an educational application for finding music albums and vi

 GCDTimer - Well tested Grand Central Dispatch (GCD) Timer in Swift
GCDTimer - Well tested Grand Central Dispatch (GCD) Timer in Swift

GCDTimer Well tested Grand Central Dispatch (GCD) Timer in Swift. Checkout the test file. Usage Long running timer import GCDTimer

Well-tested GCD Timer in Swift
Well-tested GCD Timer in Swift

GCDTimer Well tested Grand Central Dispatch (GCD) Timer in Swift. Checkout the test file. Usage Long running timer import GCDTimer class Demo { in

Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]

Extremely Fast views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainabl

EasierPath is a library to make UIBezierPath easier to use
EasierPath is a library to make UIBezierPath easier to use

EasierPath is a library to make UIBezierPath easier to use. More specifically, you can write more intuitive and concise code when you draw a straight line or a curve.

A Fast Animation Engine with an Intuitive API
A Fast Animation Engine with an Intuitive API

Kinieta An Animation Engine for iOS with an Intuitive API and Readable Code! (Written in Swift 4.0.) Why another? I decided to build an Animation Engi

ChromaColorPicker - An intuitive HSB color picker built in Swift
ChromaColorPicker - An intuitive HSB color picker built in Swift

An intuitive HSB color picker built in Swift. Supports multiple selection handles and is customizable to your needs.

Intuitive date handling in Swift

Timepiece Intuitive date handling in Swift Features 💡 Intuitive: Timepiece provides a set of helpers to make date handling easier. 🕘 Correct: Using

FlexLayout adds a nice Swift interface to the highly optimized facebook/yoga flexbox implementation. Concise, intuitive & chainable syntax.
FlexLayout adds a nice Swift interface to the highly optimized facebook/yoga flexbox implementation. Concise, intuitive & chainable syntax.

FlexLayout adds a nice Swift interface to the highly optimized Yoga flexbox implementation. Concise, intuitive & chainable syntax. Flexbox is an incre

Make your table view expandable just by implementing one method.
Make your table view expandable just by implementing one method.

ExpyTableView About ExpyTableView is a re-write based on SLExpandableTableView. Takes some ideas, concepts and codes and regenerates them in Swift. Le

NVDate is an extension of NSDate class (Swift4), created to make date and time manipulation easier.

NVDate is an extension of NSDate class (Swift4), created to make date and time manipulation easier. NVDate is testable and robust, we wrote intensive test to make sure everything is safe.

Overload +-*/ operator for Swift, make it easier to use (and not so strict)

Easy-Cal-Swift Overview This file is an overloading of +-*/ operator for Swift, to make it easier to use (and not so strict) It can make your life wit

A beautiful set of predefined colors and a set of color methods to make your iOS/OSX development life easier.
A beautiful set of predefined colors and a set of color methods to make your iOS/OSX development life easier.

Installation Drag the included Colours.h and Colours.m files into your project. They are located in the top-level directory. You can see a demo of how

A small set of utilities to make working with CoreData and Swift a bit easier.

SuperRecord =================== SUPPORTS SWIFT 2.0 from Version = 1.4 ** SUPPORTS SWIFT 1.2 from Version = 1.3 Both iOS and WatchOS A Swift CoreData

Tiny YOLO for iOS implemented using CoreML but also using the new MPS graph API.
Tiny YOLO for iOS implemented using CoreML but also using the new MPS graph API.

YOLO with Core ML and MPSNNGraph This is the source code for my blog post YOLO: Core ML versus MPSNNGraph. YOLO is an object detection network. It can

SugarRecord is a persistence wrapper designed to make working with persistence solutions like CoreData in a much easier way.
SugarRecord is a persistence wrapper designed to make working with persistence solutions like CoreData in a much easier way.

What is SugarRecord? SugarRecord is a persistence wrapper designed to make working with persistence solutions like CoreData in a much easier way. Than

KDEDateLabel is an UILabel subclass that updates itself to make time ago's format easier.
KDEDateLabel is an UILabel subclass that updates itself to make time ago's format easier.

KDEDateLabel KDEDateLabel is an UILabel subclass that saves you from refreshing it when using 'time ago' format. Installation You have multiple choice

Comments
Owner
João Mourato
João Mourato
Well-tested GCD Timer in Swift

GCDTimer Well tested Grand Central Dispatch (GCD) Timer in Swift. Checkout the test file. Usage Long running timer import GCDTimer class Demo { in

Hemanta Sapkota 183 Sep 9, 2022
async and await for Swift.

async and await for Swift. Usage Beta version. New docs soon... Contribute If you have any problems or need more information, please open an issue usi

Alecrim 88 Sep 9, 2022
Pretty GCD calls and easier code execution.

Threader Pretty GCD calls and easier code execution. Overview Threader makes GCD calls easy to read & write. It also provides a simple way to execute

Mitch Treece 35 Sep 9, 2022
This app is a sample app that recognizes specific voice commands such as "make it red", "make it blue", "make it green", and "make it black" and change the background color of the view in the frame.

VoiceOperationSample This app is a sample app that recognizes specific voice commands such as "make it red", "make it blue", "make it green", and "mak

Takuya Aso 3 Dec 3, 2021
A tiny library makes uploading and downloading easier

Features uploading/downloading multiple files concurrently or sequentially grouping tasks with awesome custom operators (||| and -->) supports backgro

Le Van Nghia 450 Nov 19, 2022
Just For Fun - tiny easy apps, refresher for swift basics

Stanford Swift Education - Very Basic - Refresher Some useful hints: Outlet types: Outlet Action Outlet Collection with Index - very useful Debugger l

Anton Veldanov 0 Nov 14, 2021
Simple and intuitive iOS chart library. Contribution graph, clock chart, and bar chart.

TEAChart Simple and intuitive iOS chart library, for Pomotodo app. Contribution graph, clock chart, and bar chart. Supports Storyboard and is fully ac

柳东原 · Dongyuan Liu 1.2k Nov 29, 2022
Intuitive cycling tracker app for iOS built with SwiftUI using Xcode. Features live route tracking, live metrics, storage of past cycling routes and many customization settings.

GoCycling Available on the iOS App Store https://apps.apple.com/app/go-cycling/id1565861313 App Icon About Go Cycling is a cycling tracker app built e

Anthony Hopkins 64 Dec 19, 2022
Intuitive and powerful Auto Layout library

Align introduces a better alternative to Auto Layout anchors. Semantic. Align APIs focus on your goals, not the math behind Auto Layout constraints. P

Alexander Grebenyuk 338 Oct 18, 2022
Queuer is a queue manager, built on top of OperationQueue and Dispatch (aka GCD).

Queuer is a queue manager, built on top of OperationQueue and Dispatch (aka GCD). It allows you to create any asynchronous and synchronous task easily, all managed by a queue, with just a few lines.

Fabrizio Brancati 1k Dec 2, 2022