explaingit

duemunk/async

4,563SwiftAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

Async is a Swift library that makes running background tasks on Apple devices simpler, replacing deeply nested code with a clean chain of steps. Note: this project is no longer maintained.

Mindmap

mindmap
  root((async))
    What it does
      Background tasks
      Chained steps
      Parallel work
    Key Features
      AsyncGroup
      Apply utility
      Priority levels
    Tech Stack
      Swift
      Apple platforms
    Install
      Swift Package Manager
      CocoaPods
      Carthage
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Run a slow operation in the background and update the screen when done, without messy nested code

USE CASE 2

Fire off several parallel tasks and wait for all of them to finish before moving on

USE CASE 3

Run the same block of code many times in parallel for batch processing tasks

Tech stack

SwiftSwift Package ManagerCocoaPodsCarthage

Getting it running

Difficulty · easy Time to first run · 30min

No longer maintained, evaluate alternatives before using in new projects.

Use freely for any purpose including commercial use, as long as you keep the copyright notice.

In plain English

Async is a Swift library for Apple platforms (macOS, iOS, tvOS, watchOS) that makes it easier to write code that runs in the background. On Apple devices, the system for managing background work is called Grand Central Dispatch, and by default using it requires nested, indented blocks of code that can be hard to read when you need to chain several steps together. This library flattens that into a simple chain of dot-connected steps. Instead of writing three nested levels of code to do something in the background, then format a result, then update the screen, you write it in a straight line: start a background task, chain a formatting step, chain a screen update. Each step runs after the previous one finishes, and you can choose what priority level each step should run at, whether that is a high-priority user-facing task or a low-priority background operation. The library also includes AsyncGroup, which handles the case where you want to fire off several blocks of work at the same time and wait for all of them to complete before moving on. You start the group, add as many parallel tasks as you need, and then call wait to pause until they are all done. There is also an Apply utility that runs a block of code many times in parallel, similar to a fast parallel for loop, though the README notes this blocks until all iterations are done. Installation is supported via Swift Package Manager, CocoaPods, and Carthage. The README notes a known issue with certain GCD queue types behaving unexpectedly in the iOS Simulator. The project is released under the MIT license. This project is no longer maintained, as stated at the top of the README. Anyone evaluating it for new projects should account for that before adopting it.

Copy-paste prompts

Prompt 1
Using the duemunk/Async Swift library, show me how to fetch data in the background and then update the UI on the main thread using a chain of async calls
Prompt 2
How do I use AsyncGroup from duemunk/Async to run three network requests in parallel and wait for all of them to finish before proceeding?
Prompt 3
Show me how to replace nested GCD DispatchQueue.async calls with the Async library dot-chained syntax in Swift
Prompt 4
How do I set different priority levels for steps in an Async chain so some run at high priority and others at background priority?
Open on GitHub → Explain another repo

← duemunk on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.