-
Notifications
You must be signed in to change notification settings - Fork 433
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 asyncStream
and asyncThrowingStream
for Signal
and SignalProducer
#847
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome 👏
Interestingly the macCatalyst issue is known in Xcode 13.2 Beta |
|
||
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, *) | ||
extension Signal { | ||
public var asyncThrowingStream: AsyncThrowingStream<Value, Swift.Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use AsyncStream<Result<Value, Error>>
to maintain the error type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump
switch event { | ||
case .value(let value): | ||
continuation.yield(value) | ||
case .completed, .interrupted: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the interrupted
event throw a swift CancellationError
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point
This is a proposal to add
asyncStream
andasyncThrowingStream
in order to bridge into Swift Concurrency.I find this especially useful for writing non-blocking async tests.
A couple of things I'd love to hear your thoughts on (apart from the usual review):
Note: Mac Catalyst builds are failing to launch on pre-monterey macOS versions: There is a workaround described in the documents but probably not worth implementing in the CI. More info here.