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

PubSub.subscribe - check validity of func? #29

Closed
m-btts opened this issue Aug 5, 2013 · 3 comments
Closed

PubSub.subscribe - check validity of func? #29

m-btts opened this issue Aug 5, 2013 · 3 comments

Comments

@m-btts
Copy link

m-btts commented Aug 5, 2013

Would it be possible to add a check to in the subscribe function that func is actually a function. Currently if func is undefined or not a function the error only occurs when the message is published

PubSub.subscribe = function( message, func )

Or do you think this is necessary/unlikely that is it not worth checking?

Many thanks

.

@mroderick
Copy link
Owner

It's absolutely possible.

I see two ways of handling this.

  1. Fail silently
    If there is no function passed to subscribe, then we return false, and do nothing more.
  2. Create exception
    If there is no function passed to subscribe, then we throw an exception and do nothing more

While I would prefer option 2, I think that option 1 is a smaller change from current behaviour, so for the sake of easy upgrades, that should probably be the option for now.

Perhaps in v2.x we can throw exceptions when users of the library are doing silly things

@m-btts
Copy link
Author

m-btts commented Aug 5, 2013

Thank you for the speedy response - failing silently seems a sensible approach for v1.x.

@mroderick
Copy link
Owner

This has been fixed with #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

No branches or pull requests

2 participants