-
Notifications
You must be signed in to change notification settings - Fork 97
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
Make add and remove callbacks take lists of message for convenience #174
Conversation
Test PASSed. |
""" | ||
self.callbacks[msg_type].add(callback) | ||
if not isinstance(msg_type, list): |
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 generalized to all iterables. The most "pythonic" way to check if something is an iterable is just to assume it is and catch failure:
try:
for mt in msg_type:
self.callbacks[mt].add(callback)
except TypeError:
self.callbacks[msg_type].add(callback)
http://stackoverflow.com/questions/1952464/in-python-how-do-i-determine-if-an-object-is-iterable
Test PASSed. |
Moved to iterable and added some tests. |
Message type to register callback against. Default `None` means global callback. | ||
List type adds the callback to all the message types. |
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.
Still a "List" here
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.
But maybe that more instructive?
Love it |
lgtm |
Test PASSed. |
Fixed the docs. Bringing in. |
Make add and remove callbacks take lists of message for convenience
Test PASSed. |
…1412) Automated PR by Jenkins. If CI has passed successfully, merge away! **cmake** 117b3f73 -> 68306be8 - 68306be8 : ASIO gRPC boost container fix (swift-nav/cmake#174) This pull request was created by https://jenkins.ci.swift-nav.com/job/CI%20Infra/job/submodule-update/17362/.
Check to see if the msg_type is a list, and then apply the callbacks to all the message types. Better way to do something like this?
/cc @fnoble @denniszollo