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

Fix filter operation #2367

Merged
merged 1 commit into from Sep 16, 2015
Merged

Fix filter operation #2367

merged 1 commit into from Sep 16, 2015

Conversation

bencochran
Copy link
Contributor

A bug snuck in with #2354 causing filter to forward events when the predicate was false. This brings back some nesting to fix that.

@@ -228,8 +228,10 @@ extension SignalType {
public func filter(predicate: T -> Bool) -> Signal<T, E> {
return Signal { observer in
return self.observe { event in
if case let .Next(value) = event where predicate(value) {
sendNext(observer, value)
if case let .Next(value) = event {
Copy link
Member

Choose a reason for hiding this comment

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

Huh, wasn't the previous implementation equivalent? 😰

Copy link
Member

Choose a reason for hiding this comment

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

Oh, duh, that was going to the else branch!

Copy link

Choose a reason for hiding this comment

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

Oops! Sorry for the bug...

@NachoSoto
Copy link
Member

Thanks a lot! I imagine the tests caught this though, right? (Even though we're not running them yet, see #2351).

@NachoSoto NachoSoto added this to the 4.0 milestone Sep 16, 2015
@NachoSoto NachoSoto added the bug label Sep 16, 2015
@bencochran
Copy link
Contributor Author

Tests first crash in ignoreNil, but they also fail on filter if I leave those tests out.

@NachoSoto
Copy link
Member

Makes sense!

NachoSoto added a commit that referenced this pull request Sep 16, 2015
@NachoSoto NachoSoto merged commit 17d5e77 into ReactiveCocoa:swift2 Sep 16, 2015
@bencochran bencochran deleted the Fix-Filter branch September 16, 2015 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants