Skip to content

Commit 1f246a7

Browse files
committed
Add starts to a channel guide
1 parent 21d92f4 commit 1f246a7

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

Guides/Channel.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Channel
2+
3+
* Author(s): [Philippe Hausler](https://github.com/phausler)
4+
5+
[
6+
[Source](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/AsyncChannel.swift),
7+
[Source](https://github.com/apple/swift-async-algorithms/blob/main/Sources/AsyncAlgorithms/AsyncThrowingChannel.swift) |
8+
[Tests](https://github.com/apple/swift-async-algorithms/blob/main/Tests/AsyncAlgorithmsTests/TestChannel.swift)
9+
]
10+
11+
## Introduction
12+
13+
## Proposed Solution
14+
15+
```swift
16+
public final class AsyncChannel<Element: Sendable>: AsyncSequence, Sendable {
17+
public struct Iterator: AsyncIteratorProtocol, Sendable {
18+
public mutating func next() async -> Element?
19+
}
20+
21+
public init(_ elementType: Element.Type = Element.self)
22+
23+
public func send(_ element: Element) async
24+
public func finish() async
25+
26+
public func makeAsyncIterator() -> Iterator
27+
}
28+
29+
public final class AsyncThrowingChannel<Element: Sendable, Failure: Error>: AsyncSequence, Sendable {
30+
public struct Iterator: AsyncIteratorProtocol, Sendable {
31+
public mutating func next() async throws -> Element?
32+
}
33+
34+
public init(_ elementType: Element.Type = Element.self)
35+
36+
public func send(_ element: Element) async
37+
public func fail(_ error: Error) async where Failure == Error
38+
public func finish() async
39+
40+
public func makeAsyncIterator() -> Iterator
41+
}
42+
```
43+
44+
## Detailed Design
45+
46+
## Alternatives Considered
47+
48+
It was consider to use the naming heritage of "subject".
49+
50+
## Credits/Inspiration

0 commit comments

Comments
 (0)