Problem Description
I personally find it very confusing to have a trait named thing_changed = Event which explicitly gets set to True when thing changes. Chaco will often listen to that trait when setting up change handlers, but I am not seeing why we couldn't just listen to the trait itself. e.g why do something like observe(_____, thing_changed) instead of just observe(_____, thing).
I may be missing something important as to why this is needed but as far as I can tell it is not.
See #601 which removed the metadata_changed event trait. Other examples include:
|
#: Event fired when the index data changes. Subclasses can listen for this |
|
#: event and take appropriate steps (except for requesting a redraw, which |
|
#: is done in this class). |
|
index_data_changed = Event |
|
|
|
#: Event fired when the index mapper changes. Subclasses can listen for this |
|
#: event and take appropriate steps (except for requesting a redraw, which |
|
#: is done in this class). |
|
index_mapper_changed = Event |
|
|
|
#: Event fired when the value data changes. Subclasses can listen for this |
|
#: event and take appropriate steps (except for requesting a redraw, which |
|
#: is done in this class). |
|
value_data_changed = Event |
|
def _update_index_data(self, event=None): |
|
""" Updates the index data. |
|
|
|
Called by various trait change handlers. |
|
""" |
|
self.index_data_changed = True |
|
self.invalidate_draw() |
|
def _index_changed(self, old, new): |
|
if old is not None: |
|
old.obseve(self._update_index_data, "data_changed", remove=True) |
|
if new is not None: |
|
new.obseve(self._update_index_data, "data_changed") |
|
self._update_index_data() |
|
|
|
def _value_changed(self, old, new): |
|
if old is not None: |
|
old.observe(self._update_value_data, "data_changed", remove=True) |
|
if new is not None: |
|
new.observe(self._update_value_data, "data_changed") |
|
self._update_value_data() |
|
|
|
def _index_mapper_changed(self, old, new): |
|
if old is not None: |
|
old.observe(self._update_index_mapper, "updated", remove=True) |
|
if new is not None: |
|
new.observe(self._update_index_mapper, "updated") |
|
self._update_index_mapper() |
In any case, if there is a reason that something like this needs to be done, we should still make an effort to clean this code up and make it more easily understandable / better documented of why things are like this.
Problem Description
I personally find it very confusing to have a trait named
thing_changed = Eventwhich explicitly gets set toTruewhenthingchanges. Chaco will often listen to that trait when setting up change handlers, but I am not seeing why we couldn't just listen to the trait itself. e.g why do something likeobserve(_____, thing_changed)instead of justobserve(_____, thing).I may be missing something important as to why this is needed but as far as I can tell it is not.
See #601 which removed the
metadata_changedevent trait. Other examples include:chaco/chaco/base_2d_plot.py
Lines 63 to 76 in ef72277
chaco/chaco/base_2d_plot.py
Lines 278 to 284 in ef72277
chaco/chaco/base_2d_plot.py
Lines 313 to 332 in ef72277
In any case, if there is a reason that something like this needs to be done, we should still make an effort to clean this code up and make it more easily understandable / better documented of why things are like this.