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

swing.Publisher calls PartialFunction listeners for undefined values #8019

Closed
scabug opened this issue Nov 29, 2013 · 3 comments
Closed

swing.Publisher calls PartialFunction listeners for undefined values #8019

scabug opened this issue Nov 29, 2013 · 3 comments
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Nov 29, 2013

Publisher has a list of listeners of the Reaction type (ie PartialFunction[Event, Unit]), but publishes events to all listeners, even if the Reaction is not defined for that value:

https://github.com/scala/scala/blob/6ff3c3fd/src/swing/scala/swing/Publisher.scala#L47

A Coursera thread with people affected by this issue:

https://class.coursera.org/reactive-001/forum/thread?thread_id=1315

will pull request shortly...

@scabug
Copy link
Author

@scabug scabug commented Nov 29, 2013

Imported From: https://issues.scala-lang.org/browse/SI-8019?orig=1
Reporter: @rtyley
Affected Versions: 2.10.3

@scabug
Copy link
Author

@scabug scabug commented Nov 29, 2013

@rtyley said:
Pull Request submitted with scala/scala#3205

@scabug scabug closed this Dec 9, 2013
@scabug
Copy link
Author

@scabug scabug commented Dec 23, 2013

@Sciss said:
This is a possibly expensive fix. If you look at https://github.com/rtyley/scala/blob/4ef949da930c2797e46fb206ea541da54811d9ba/src/swing/scala/swing/Reactions.scala#L23 you see that Reactions.Impl's apply again needs to call isDefined for each registered function, so now with standard reactions isDefined will be called twice. That's probably why publish took the shortcut.

The better solution IMO would be to make subscribe package private.

An immediate improvement could be to check the listener for Reactions in publish, and then shortcutting to apply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants