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

Add conformance to SignalProducerConvertible for Result #606

Merged
merged 6 commits into from
Feb 21, 2018

Conversation

Qata
Copy link
Contributor

@Qata Qata commented Feb 14, 2018

Checklist

@NachoSoto
Copy link
Member

That's a neat idea! Any chance you can add a few tests for this?

@Qata
Copy link
Contributor Author

Qata commented Feb 14, 2018

I didn't because there isn't any current conformance tests at all, but I can.


extension Result: SignalProducerConvertible {
public var producer: SignalProducer<Value, Error> {
switch self {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the initializer here:

public init(result: Result<Value, Error>) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do, but perhaps that should now be deprecated in favour of using the protocol?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

@Qata
Copy link
Contributor Author

Qata commented Feb 14, 2018

@NachoSoto Tests added.

@@ -484,6 +484,34 @@ class SignalProducerSpec: QuickSpec {
expect(error) == operationError
}
}

describe("init(_:) base") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be Result.producer, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well technically I'm testing SignalProducer.init(_ base:) as well but I can call it Result.producer.

error = $0
}

expect(error).to(beNil())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should check that the value was sent, and that it completed.

@Qata
Copy link
Contributor Author

Qata commented Feb 14, 2018

@NachoSoto Amended tests to address comments.

CHANGELOG.md Outdated
@@ -1,6 +1,7 @@
# master
*Please add new entries at the top.*

1. New conformance of `Result` to `SignalProducerConvertible` (#606, kudos to @Qata)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this?

Result now interoperates with SignalProducer n-ary operators as a constant producer.

@Qata
Copy link
Contributor Author

Qata commented Feb 15, 2018

@andersio Amended

Copy link
Member

@RuiAAPeres RuiAAPeres left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite nice. 👍

@andersio andersio merged commit c7bf379 into ReactiveCocoa:master Feb 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants