Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add async do(_:) for Swift Concurrency #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

spnkr
Copy link

@spnkr spnkr commented Jan 5, 2025

Adds an async version of .do(_:) so Then can handle asynchronous closures. It’s conditionally compiled and doesn’t break existing synchronous usage.

Changes

  • Introduces a new do(_:) with an async closure, gated by #if swift(>=5.5) && canImport(_Concurrency) and @available(iOS 13, macOS 10.15, etc.).
  • Leaves the original synchronous do(_:) untouched.

Why

Avoids "cannot pass async closure to parameter expecting synchronous function type" errors.

Allows writing:

await object.do {  
  await someAsyncCall() 
}

Compatibility

No breaking changes. Earlier Swift or platforms without concurrency continue using the sync do(_:).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant