mirror of
https://github.com/apple/swift-async-algorithms
synced 2026-11-25 04:27:48 +00:00
* Rebase guides WIP to avoid source changes * Add prose for debounce and throttle * Add an alterantive for debounce * Starts to prose for reductions * Add effect listings for all types * Add some examples for reductions * Update Guides/Channel.md Co-authored-by: Chris Adamson <invalidname@gmail.com> * Update Guides/Channel.md Co-authored-by: Chris Adamson <invalidname@gmail.com> * Update Guides/Channel.md Co-authored-by: Chris Adamson <invalidname@gmail.com> * Update Guides/Channel.md Co-authored-by: Chris Adamson <invalidname@gmail.com> * Update Guides/Collections.md Co-authored-by: Chris Adamson <invalidname@gmail.com> * Update Guides/Throttle.md Co-authored-by: Chris Adamson <invalidname@gmail.com> * Update Guides/Throttle.md Co-authored-by: Chris Adamson <invalidname@gmail.com> * Update Guides/Throttle.md Co-authored-by: Chris Adamson <invalidname@gmail.com> * Update Sources/AsyncAlgorithms/AsyncInclusiveReductionsSequence.swift Co-authored-by: Chris Adamson <invalidname@gmail.com> * Adjust events to elements for channels * Add a bit more detail to the README and a start to the guide for Task.select * Chunked updates * Add a getting started section to the README * Add some more prose for Channel * Update Guides/RemoveDuplicates.md Co-authored-by: Chris Adamson <invalidname@gmail.com> * Apply suggestions from code review Co-authored-by: Chris Adamson <invalidname@gmail.com> * Add some brief prose for Compacted * reductions could be named scan * spelling and correctness fixes * Apply @kperryua's suggestion for changing the intro of Compacted * Add some brief prose for Timer * Apply suggestions from code review for README Co-authored-by: Tony Parker <anthony.parker@apple.com> * Add some brief prose for RemoveDuplicates * Fleshing out of `Joined` Co-authored-by: Chris Adamson <invalidname@gmail.com> Co-authored-by: Kevin Perry <kperry@apple.com> Co-authored-by: Tony Parker <anthony.parker@apple.com>
1.3 KiB
1.3 KiB
AsyncLazySequence
Converts a non-asynchronous sequence into an asynchronous one.
This operation is available for all Sequence types.
let numbers = [1, 2, 3, 4].async
let characters = "abcde".async
This transformation can be useful to test operations specifically available on AsyncSequence but also is useful
to combine with other AsyncSequence types to provide well known sources of data.
Detailed Design
The .async property returns an AsyncLazySequence that is generic upon the base Sequence it was constructed from.
extension Sequence {
public var async: AsyncLazySequence<Self> { get }
}
public struct AsyncLazySequence<Base: Sequence>: AsyncSequence {
...
}
extension AsyncLazySequence: Sendable where Base: Sendable { }
extension AsyncLazySequence.Iterator: Sendable where Base.Iterator: Sendable { }
Naming
This property's and type's name match the naming approaches in the Swift standard library. The property is named with a
succinct name in inspiration from .lazy, and the type is named in reference to the lazy behavior of the constructed
AsyncSequence.