-
Notifications
You must be signed in to change notification settings - Fork 432
A variant of combinePrevious that doesn't need an initial value.
#445
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
Conversation
8ca80a5 to
54c938b
Compare
54c938b to
df14b40
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👎🏻
This could be backwards incompatible if somebody is passing nil because Value is optional.
Furthermore I don't think changing this API is necessary (I'm generally against parameters that fundamentally change the behavior of a function) since this can be replicated with skip(first: 1)
|
🤔 Haven't considered optionals. That said we can use this just for
Not quite if you consider how many extra hops needed for |
combinePrevious optional.combinePrevious that doesn't need an initial value.
d6e7309 to
939354a
Compare
939354a to
99cfe89
Compare
|
For reference, some previous discussion on this general idea: ReactiveCocoa/ReactiveCocoa#2632 |
|
@sharplet Thanks for pointing out the previous discussion. My responses to @NachoSoto's arguments:
Both share the same implementation in this PR.
From values // Signal<U, E>
.optionalize() // Signal<U?, E>
.combinePrevious(nil) // Signal<(U?, U?), E>
.filterMap { $0.0 != nil && $0.1 != nil ? ($0.0!, $0.1!) : nil } // Signal<(U, U), E>which is hardly sane. Moreover, as shown in this PR, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new implementation is great 👍
Note that
combinePrevious()is not implemented using default arguments and optionals, so that existing use cases as concerned by @NachoSoto would not break.In other words,
combinePrevious(nil)andcombinePrevious()are not equivalent, given the constraint<U> Value == Optional<U>.Checklist