This release rounds out FP's async toolkit with concurrent combinators — race several operations for the first success, or bound an operation with a timeout — and aligns the parallel-combine helper with Swift's with… scoped-operation naming.
💥 Breaking Changes
-
flattenAsyncis nowwithAll. The helper that runs several asyncResultoperations in parallel and combines them into a tuple (failing on the first error) has been renamed for consistency with the newwith…family. Behavior and the 2–10 argument forms are unchanged — only the name differs.// Before let result = await flattenAsync(await fetchUser(), await fetchSettings()) // After let result = await withAll(await fetchUser(), await fetchSettings())
The synchronous
flatten(for combining already-computedResults) is unchanged.
✨ New Features
-
withAny— race for the first success. Runs several async operations concurrently and returns the first one to finish with a success, cancelling the rest. A fast failure doesn't win: failures are passed over while the other operations keep running, and only if every operation fails is the last failure returned. It's the natural counterpart towithAll(all-must-succeed vs. any-one-succeeds).// Hit several mirrors, take whichever responds successfully first let data = await withAny( await fetch(from: primaryMirror), await fetch(from: backupMirror), await fetch(from: archiveMirror) )
Supports 2–10 operations via the variadic form, or any number via an array of closures for dynamic operation counts.
-
withTimeout— give an operation a deadline. Runs an operation and returns its result if it finishes within the given duration, or.failure(timeoutError)if it doesn't — cancelling the operation when the timeout wins. A failure that arrives before the deadline is returned as-is, never replaced by the timeout error.let user = await withTimeout(.seconds(5), failingWith: .timeout) { await fetchUser(id) }
Requires macOS 13+ / iOS 16+ / tvOS 16+ / watchOS 9+ / visionOS 1+ (it takes a
Duration).
📚 Documentation
- Added Swift Package Index badges and links to the hosted DocC documentation in the README.