{"id":1154,"url":"https://github.com/JARMourato/Dispatch","last_synced_at":"2025-07-30T20:32:35.374Z","repository":{"id":56908583,"uuid":"58569730","full_name":"JARMourato/Dispatch","owner":"JARMourato","description":"Just a tiny library to make using GCD easier and intuitive","archived":true,"fork":false,"pushed_at":"2017-11-14T19:26:09.000Z","size":507,"stargazers_count":178,"open_issues_count":0,"forks_count":21,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-05-22T15:21:36.487Z","etag":null,"topics":["async","gdc","multithreading","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JARMourato.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-11T18:19:36.000Z","updated_at":"2023-06-07T13:32:52.000Z","dependencies_parsed_at":"2022-08-20T19:50:31.330Z","dependency_job_id":null,"html_url":"https://github.com/JARMourato/Dispatch","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JARMourato%2FDispatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JARMourato%2FDispatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JARMourato%2FDispatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JARMourato%2FDispatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JARMourato","download_url":"https://codeload.github.com/JARMourato/Dispatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228187541,"owners_count":17882322,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","gdc","multithreading","swift"],"created_at":"2024-01-05T20:15:40.081Z","updated_at":"2024-12-04T20:31:02.542Z","avatar_url":"https://github.com/JARMourato.png","language":"Swift","funding_links":[],"categories":["GCD"],"sub_categories":["Getting Started","Other free courses","Linter"],"readme":"\u003cimg src=\"https://raw.githubusercontent.com/Swiftification/Dispatch/master/icon.png\" alt=\"Dispatch\" width=140/\u003e\n## Build Status\n\n|**Branch**| **Status** |\n|---|---|\n|**master** |[![Bunch Status](https://travis-ci.org/Swiftification/Dispatch.svg?branch=master)](https://travis-ci.org/Swiftification/Dispatch)|\n|**develop** |[![Bunch Status](https://travis-ci.org/Swiftification/Dispatch.svg?branch=develop)](https://travis-ci.org/Swiftification/Dispatch)|\n\n## Dispatch\n\n[![Swift 3.0](https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat)](https://developer.apple.com/swift/)\n![Platforms](https://img.shields.io/cocoapods/p/Dispatch.svg?style=flat)\n[![License](https://img.shields.io/cocoapods/l/Dispatch.svg)](https://github.com/DynamicThreads/Dispatch/master/LICENSE)\n\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) \n![Podspec](https://img.shields.io/cocoapods/v/Dispatch.svg)\n\n\n[![codebeat badge](https://codebeat.co/badges/b3876506-e737-4e78-b505-ed193a1e3869)](https://codebeat.co/projects/github-com-swiftification-dispatch)\n[![codecov](https://codecov.io/gh/Swiftification/Dispatch/branch/master/graph/badge.svg)](https://codecov.io/gh/S/Dispatch)\n\n#### Note: \n\nDispatch requires swift 3.0. Use version 1.0.0 for swift 2.3 or version 0.9.8 for swift 2.2.\n\n## Installation\n\n#### CocoaPods\n\nDispatch is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'Dispatch'\n```\n\n## Carthage\n----------------\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.\n\nYou can install Carthage with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate Dispatch into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"Swiftification/Dispatch\"\n```\n\nRun `carthage update` to fetch the Dispatch library and drag into your Xcode project.\n\n\nAnd then simply\n\n``` swift\nimport DispatchFramework\n```\n\nAnd your good to go!\n\n#### Manually\n\n1. Download and drop ```Dispatch.swift``` anywhere you like in your project.  \n2. That's it.\n\n## Usage\n\n### Basic\n\n```swift\nDispatch.async(dispatch_get_main_queue()) {\n  //Code to be run on the main thread\n}\n```\n\n##### Or using the helpers provided by Dispatch.Queue enum \n\n```swift\nDispatch.async(Queue.main) {\n  //Code to be run on the main thread\n}\n```\n\n##### Or using the overloaded method to run on the main thread\n\n```swift\nDispatch.async {\n  //Code to be run on the main thread\n}\n```\n\n### Types of Dispatch\n\n#### Async\n\n```swift\nDispatch.async(Queue.main) {\n  //Code to be run on the main thread\n}\n```\n\n#### Sync\n\n```swift\nlet someCustomQueue = dispatch_queue_create(\"custom.queue.dispatch\", DISPATCH_QUEUE_CONCURRENT)\nDispatch.sync(someCustomQueue) {\n  //Code to be synchronously on someCustomQueue\n}\n```\n\n#### After\n\n```swift\nDispatch.after(1.0, queue: Queue.main) {\n  //Code to be run on the main thread after 1 second\n}\n```\n##### Or using the overloaded method to run on the main thread\n\n```swift\nDispatch.after(1.0) {\n  //Code to be run on the main thread after 1 second\n}\n```\n\n#### Once\n\n```swift\nlet token : dispatch_once_t\nDispatch.once(\u0026token) {\n  //Code to be run only once in App lifetime\n}\n```\n\n### Queue Helpers\n\n#### Main queue\n\n```swift\nlet mainQueue = Queue.main \n```\n\n#### Custom queue\n\n```swift\nlet customConcurrentQueue = Queue.custom(\"custom.concurrent.queue.dispatch\", Queue.Atribute.concurrent)\nlet customSerialQueue = Queue.custom(\"custom.serial.queue.dispatch\", Queue.Atribute.serial)\n```\n\n#### Global queues\n\n```swift\nlet priority = 0 // or you use one of the Global priorities (ex: Queue.Priority.UserInteractive)\nlet globalQueue = Queue.global(priority)\n\n// For comodity there are helpers for getting the Global queues\n\nlet globalUserInteractiveQueue = Queue.globalUserInteractive\nlet globalUserInitiatedQueue = Queue.globalUserInitiated\nlet globalUtilityQueue = Queue.globalUtility\nlet globalBackgroundQueue = Queue.globalBackground\n```\n\n## TODO\n\n- [X] Carthage compatible\n- [X] Chainable methods\n- [X] Travis CI\n- [X] Unit Tests\n- [ ] More examples\n\n## Communication\n\n- If you **find a bug**, open an issue.\n- If you **have a feature request**, open an issue.\n- If you **want to contribute**, submit a pull request.\n\n## Authors\n\n- João Mourato, joao.armourato@gmail.com\n\n- Gabriel Peart\n\n## License\n\nDispatch is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJARMourato%2FDispatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJARMourato%2FDispatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJARMourato%2FDispatch/lists"}