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 merge operator for SignalProducer #2925

Merged

Conversation

larryonoff
Copy link
Contributor

It often usable to use merge operator for SignalProducer. Signal already has merge operator.

/// from each of them, and complete when all of them have completed.
@warn_unused_result(message="Did you forget to call `start` on the producer?")
public static func merge<Value, Error: ErrorType>(producers: SignalProducer<Value, Error>...) -> SignalProducer<Value, Error> {
return SignalProducer(values: producers).flatten(.Merge)
Copy link
Contributor

Choose a reason for hiding this comment

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

This could just call the above variant and pass producers.

@mdiep
Copy link
Contributor

mdiep commented May 23, 2016

Thanks for the PR! I agree this is a handy thing to have.

@larryonoff
Copy link
Contributor Author

Thank you for the comments! I've updated this PR according to your comments.

@larryonoff
Copy link
Contributor Author

What do you think about the case when combineLatest and zip operators are free functions, when merge is not.

Maybe it's better to move merge operator from protocols?

@ikesyo
Copy link
Member

ikesyo commented May 23, 2016

What do you think about the case when combineLatest and zip operators are free functions, when merge is not.

Maybe it's better to move merge operator from protocols?

@larryonoff That should be discussed in #2926.

@larryonoff
Copy link
Contributor Author

@ikesyo thanks!

@@ -1893,6 +1893,71 @@ class SignalProducerSpec: QuickSpec {
expect(started) == false
}
}

describe("SignalProducer.merge") {
Copy link
Member

Choose a reason for hiding this comment

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

I think this (and describe("Signal.merge") in SignalSpec.swift) should be defined in FlattenSpec.swift.

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 move it.

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

@larryonoff
Copy link
Contributor Author

Signal.merge() and SignalProducer.merge() moved into FlattenSpec.

@mdiep
Copy link
Contributor

mdiep commented May 23, 2016

This is great! Thanks for the PR. ✨

@mdiep mdiep merged commit a6632e0 into ReactiveCocoa:master May 23, 2016
@larryonoff larryonoff deleted the feature/signal-producer-add-merge branch May 23, 2016 20:30
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

3 participants