-
Notifications
You must be signed in to change notification settings - Fork 24
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 on_trait_change with observe #285
Conversation
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.
LGTM with a few comments/suggestions.
@@ -121,7 +121,7 @@ def _initialize(self): | |||
""" Wire-up trait change handlers etc. """ | |||
|
|||
# Listen for the object's trait being changed. | |||
self.obj.on_trait_change(self._on_trait_changed, self.trait_name) | |||
self.obj.observe(self._on_trait_changed, self.trait_name) |
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.
looks like we don't have a good place to unhook this listener
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.
yeah I noticed this as well... not sure what the best thing to do is
Orthogonal to this PR, but we should add a "maintenance" news fragment type. I wasn't sure which of "feature, bugfix, deprecation, removal, doc, test, build" to classify this PR as, but it feels like it will be ultimately relevant for the changelog (as I imagine 5.1 of apptools main purpose will be this migration to observe / depending on traits 6.2) I am going to call it a feature for now simply because IDK where to put it. When generating the actual changelog we will want to move this, but this way it will still be picked up |
Checklist
This PR replaces almost all uses of
on_trait_change
with observe.All that remains is
apptools.selection.selection_service.py
andapptools.scripting.recorder.py
(also an undo example but that is deprecated here anyway). These are a bit trickier and can be addressed separately