@@ -734,10 +734,10 @@ strategies.
734734
735735## Alternatives considered
736736
737- ### Provide the ` onTermination ` callback to the factory method
737+ ### Provide an ` onTermination ` callback to the factory method
738738
739739During development of the new APIs, I first tried to provide the ` onTermination `
740- callback in the ` makeStream ` method. However, that showed significant usability
740+ callback in the ` makeChannel ` method. However, that showed significant usability
741741problems in scenarios where one wants to store the source in a type and
742742reference ` self ` in the ` onTermination ` closure at the same time; hence, I kept
743743the current pattern of setting the ` onTermination ` closure on the source.
@@ -746,12 +746,12 @@ the current pattern of setting the `onTermination` closure on the source.
746746
747747During the pitch phase, it was raised that we should provide a
748748` onConsumerCancellation ` callback which gets invoked once the asynchronous
749- stream notices that the consuming task got cancelled. This callback could be
750- used to customize how cancellation is handled by the stream e.g. one could
751- imagine writing a few more elements to the stream before finishing it. Right now
752- the stream immediately returns ` nil ` or throws a ` CancellationError ` when it
749+ channel notices that the consuming task got cancelled. This callback could be
750+ used to customize how cancellation is handled by the channel e.g. one could
751+ imagine writing a few more elements to the channel before finishing it. Right now
752+ the channel immediately returns ` nil ` or throws a ` CancellationError ` when it
753753notices cancellation. This proposal decided to not provide this customization
754- because it opens up the possiblity that asynchronous streams are not terminating
754+ because it opens up the possiblity that asynchronous channels are not terminating
755755when implemented incorrectly. Additionally, asynchronous sequences are not the
756756only place where task cancellation leads to an immediate error being thrown i.e.
757757` Task.sleep() ` does the same. Hence, the value of the asynchronous not
@@ -762,30 +762,19 @@ the future and we can just default it to the current behaviour.
762762### Create a custom type for the ` Result ` of the ` onProduceMore ` callback
763763
764764The ` onProducerMore ` callback takes a ` Result<Void, Error> ` which is used to
765- indicate if the producer should produce more or if the asynchronous stream
765+ indicate if the producer should produce more or if the asynchronous channel
766766finished. We could introduce a new type for this but the proposal decided
767767against it since it effectively is a result type.
768768
769769### Use an initializer instead of factory methods
770770
771- Instead of providing a ` makeStream ` factory method we could use an initializer
771+ Instead of providing a ` makeChannel ` factory method we could use an initializer
772772approach that takes a closure which gets the ` Source ` passed into. A similar API
773773has been offered with the ` Continuation ` based approach and
774774[ SE-0388] ( https://github.com/apple/swift-evolution/blob/main/proposals/0388-async-stream-factory.md )
775775introduced new factory methods to solve some of the usability ergonomics with
776776the initializer based APIs.
777777
778- ### Follow the ` AsyncStream ` & ` AsyncThrowingStream ` naming
779-
780- All other types that offer throwing and non-throwing variants are currently
781- following the naming scheme where the throwing variant gets an extra ` Throwing `
782- in its name. Now that Swift is gaining typed throws support this would make the
783- type with the ` Failure ` parameter capable to express both throwing and
784- non-throwing variants. However, the less flexible type has the better name.
785- Hence, this proposal uses the good name for the throwing variant with the
786- potential in the future to deprecate the ` AsyncNonThrowingBackpressuredStream `
787- in favour of adopting typed throws.
788-
789778## Acknowledgements
790779
791780- [ Johannes Weiss] ( https://github.com/weissi ) - For making me aware how
0 commit comments