Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Feb 6, 2023. It is now read-only.
/DispatchPublic archive

Just a tiny library to make using GCD easier and intuitive

License

NotificationsYou must be signed in to change notification settings

JARMourato/Dispatch

Repository files navigation

Dispatch

## Build Status
BranchStatus
masterBunch Status
developBunch Status

Dispatch

Swift 3.0PlatformsLicense

Carthage compatiblePodspec

codebeat badgecodecov

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 throughCocoaPods. To installit, 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 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!

Manually

  1. Download and dropDispatch.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

letsomeCustomQueue=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

lettoken:dispatch_once_tDispatch.once(&token){  //Code to be run only once in App lifetime}

Queue Helpers

Main queue

letmainQueue=Queue.main

Custom queue

letcustomConcurrentQueue=Queue.custom("custom.concurrent.queue.dispatch",Queue.Atribute.concurrent)letcustomSerialQueue=Queue.custom("custom.serial.queue.dispatch",Queue.Atribute.serial)

Global queues

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

TODO

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

Communication

  • If youfind a bug, open an issue.
  • If youhave a feature request, open an issue.
  • If youwant to contribute, submit a pull request.

Authors

License

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp