https://github.com/vsanthanam/anyasyncsequence
Type-Erased Existential Generic AsyncSequence Values in Swift
https://github.com/vsanthanam/anyasyncsequence
async await ios macos structured-concurrency swift tvos watchos xcode
Last synced: 10 months ago
JSON representation
Type-Erased Existential Generic AsyncSequence Values in Swift
- Host: GitHub
- URL: https://github.com/vsanthanam/anyasyncsequence
- Owner: vsanthanam
- License: mit
- Created: 2022-05-20T02:00:15.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-06-26T12:57:19.000Z (over 2 years ago)
- Last Synced: 2025-05-10T04:01:55.339Z (10 months ago)
- Topics: async, await, ios, macos, structured-concurrency, swift, tvos, watchos, xcode
- Language: Swift
- Homepage: https://anyasyncsequence.tools
- Size: 227 KB
- Stars: 22
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# AnyAsyncSequence
[](https://github.com/vsanthanam/AnyAsyncSequence/blob/main/LICENSE)
[](https://github.com/vsanthanam/AnyAsyncSequence/releases)
[](https://img.shields.io/github/workflow/status/vsanthanam/AnyAsyncSequence/spm-build-test)
[](https://swift.org)
[](https://developer.apple.com)
AnyAsyncSequence allows you to expose `AsyncSequence` interfaces in your APIs without exposing the underlying sequence type, while continuing to expose the sequence's `Element` type to consumers, so they can asynchronously iterate over the sequence.
I assume that when Swift adds type constraints to opaque types ([as has been hinted](https://forums.swift.org/t/anyasyncsequence/50828/2)), this package may become unnecessary.
## Installation
AnyAsyncSequence currently distributed exclusively through the [Swift Package Manager](https://www.swift.org/package-manager/).
To add AnyAsyncSequence as a dependency to an existing Swift package, add the following line of code to the `dependencies` parameter of your `Package.swift` file:
```swift
dependencies: [
.package(url: "https://github.com/vsanthanam/AnyAsyncSequence.git", .upToNextMajor(from: "1.0.0"))
]
```
To add AnyAsyncSequence as a dependency to an Xcode Project:
- Choose `File` → `Add Packages...`
- Enter package URL `https://github.com/vsanthanam/AnyAsyncSequence.git` and select your release and of choice.
Other distribution mechanisms like CocoaPods or Carthage may be added in the future.
Additional installation instructions are available on the [Swift Package Index](https://swiftpackageindex.com/vsanthanam/AnyAsyncSequence)
[](https://swiftpackageindex.com/vsanthanam/AnyAsyncSequence)
[](https://swiftpackageindex.com/vsanthanam/AnyAsyncSequence)
## Usage
```swift
import AnyAsyncSequence
var mySequence: AnyAsyncSequence {
myTypedSequence.eraseToAnyAsyncSequence()
}
```
Explore [the documentation](https://anyasyncsequence.tools/docs/documentation/anyasyncsequence) for more details.
## License
**AnyAsyncSequence** is available under the MIT license. See the LICENSE file for more information.