[swift-evolution] Standard ReactiveSteam definitions for Swift

Dave DeLong swift at davedelong.com
Sat Sep 23 09:24:53 CDT 2017



> On Sep 23, 2017, at 1:24 AM, Georgios Moschovitis via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Copied from the corresponding Github issue, I would like to hear opinions from the broader community on this:
> 
> I am wondering if the correct 'translation' to Swift of:
> 
> ```
> onNext()
> onError()
> ```
> 
> is really:
> 
> ```
> on(next:)
> on(error:)
> ```

I’ve played around with reactive streams, and one of the main issues with this naming convention is that it really confuses the compiler when you try to use trailing closure syntax:

aStream.on { nextOrError in

}

The compiler has a really hard time inferring what the type of nextOrError is without explicitly typing the parameter or not using trailing closure syntax.

Using .onNext { … } or .onError { … } bypasses this problem entirely.

Dave


> maybe something closer to Foundation's naming conventions would be:
> 
> ```
> didReceive(next:) or didReceive(value:)
> didReceive(error:)
> ```
> 
> -g.
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170923/2e296837/attachment.html>


More information about the swift-evolution mailing list