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

Replace Observer.action with Observer.send. #515

Merged
merged 3 commits into from
Sep 11, 2017
Merged

Conversation

andersio
Copy link
Member

@andersio andersio commented Sep 9, 2017

Signal.Observer.action does not capture the Signal.Observer it derived from. This might cause issues with Signal inputs and transformed observer, since these rely on the lifetime of the Signal.Observer. This also implies a semantic inconsistency between action and any method reference to send*.

While patching Observer.action is sufficient, it appears to be a great opportunity to hide the closure as an implementation detail, and complete the send method family with a new overload taking the event sum type.

Checklist

  • Updated CHANGELOG.md.

@andersio andersio added the bug label Sep 9, 2017
@andersio andersio modified the milestone: 2.1 Sep 9, 2017
@andersio andersio changed the title Observer.action should inherit the semantics of the derived Observer. Replace Observer.action with Observer.send. Sep 9, 2017
@@ -11,9 +11,16 @@ extension Signal {
/// (typically from a Signal).
public final class Observer {
public typealias Action = (Event) -> Void
private let _action: Action
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like it should be called _send.

@mdiep
Copy link
Contributor

mdiep commented Sep 10, 2017

👍 on the name change

@RuiAAPeres RuiAAPeres merged commit e36900b into master Sep 11, 2017
@RuiAAPeres RuiAAPeres deleted the observer-fix branch September 11, 2017 20:59
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

3 participants