Skip to content
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

Introducing Single type #2873 #201

Closed
RuiAAPeres opened this issue Dec 30, 2016 · 9 comments
Closed

Introducing Single type #2873 #201

RuiAAPeres opened this issue Dec 30, 2016 · 9 comments
Assignees
Labels
Milestone

Comments

@RuiAAPeres
Copy link
Member

RuiAAPeres commented Dec 30, 2016

This refers to ReactiveCocoa/Reactivecocoa/#2873

@RuiAAPeres RuiAAPeres self-assigned this Dec 30, 2016
@RuiAAPeres RuiAAPeres added this to the 2.0 milestone Dec 30, 2016
@liscio
Copy link
Contributor

liscio commented Jan 12, 2017

I don't see the value of having a new type to represent this.

As a consumer of an API like ReactiveSwift, I think it's nice and compact to think in terms of the two major constructs (Signal and SignalProducer). If you wanted to represent something like a Future using a Single, then I'd argue a SignalProducer makes far more sense because the caller is in control of kicking off the process that results in the value they are looking for. The same goes for SignalProducer.init(value:) or SignalProducer.init(error:)—it nicely captures the narrow scope of the created producer.

Furthermore, if the caller of an API vending a Signal{,Producer} is concerned about ensuring they only get a single value, then take(1) is a succinct way to assert exactly that in the code.

Perhaps a few examples of ReactiveSwift (pseudo-)code that'd be improved by Single would help sway my current 👎 attitude towards this. :)

@andersio
Copy link
Member

andersio commented Jan 12, 2017

I'd like to see if it could bring additional compile time guarantee over SignalProducer. AFAIK there is no way (and no plan) to have an attribute to guarantee that a closure can only be invoked once. So in the end, in terms of the static API contract it could very well be an equivalent of SignalProducer.

A new type also adds more overloads to our lifting-based operator model, and the maintenance cost has to be considered too.

@RuiAAPeres
Copy link
Member Author

👍

@NachoSoto
Copy link
Member

I'm also a big opponent of this idea (happy to explain why).

@mdiep
Copy link
Contributor

mdiep commented Feb 8, 2017

I'd love to hear your thoughts @NachoSoto

@NinoScript
Copy link

I'm really interested in why this may not be a good idea. @NachoSoto ?

@RuiAAPeres
Copy link
Member Author

ping @NachoSoto 😛

@andersio
Copy link
Member

andersio commented Jun 20, 2017

ping @NachoSoto 😸

@Qata
Copy link
Contributor

Qata commented Aug 9, 2017

ping @NachoSoto 🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants