Skip to content

Replace dynamic on_trait_change with observe#590

Merged
aaronayres35 merged 22 commits into
masterfrom
replace-dynamic-on_trait_change
Apr 2, 2021
Merged

Replace dynamic on_trait_change with observe#590
aaronayres35 merged 22 commits into
masterfrom
replace-dynamic-on_trait_change

Conversation

@aaronayres35
Copy link
Copy Markdown
Contributor

@aaronayres35 aaronayres35 commented Mar 31, 2021

This PR starts replacing the dynamic uses of on_trait_change with observe equivalents

I am going to arbitrarily stop here to keep this PR shorter to review. After these changes, there are 18 files left containing .on_trait_change which can be addressed in a separate PR.

Comment on lines +112 to +120

self.datasource_change_handler(
TraitChangeEvent(
object=new,
name="color_data",
old=None,
new=new.color_data
)
)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is certainly a pattern we would like to avoid. For now I just went with the most straightforward transition possible to preserve behavior, but at some point we should rethink this

@aaronayres35 aaronayres35 changed the title [WIP] Replace dynamic on_trait_change with observe Replace dynamic on_trait_change with observe Mar 31, 2021
Copy link
Copy Markdown
Contributor

@rahulporuri rahulporuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM with a few suggestions

Comment thread chaco/axis.py Outdated
Comment thread chaco/base_1d_mapper.py Outdated
Comment thread chaco/base_2d_plot.py Outdated
Comment thread chaco/base_2d_plot.py Outdated
Comment thread chaco/base_2d_plot.py Outdated
Comment thread chaco/overlays/databox.py Outdated
Comment thread chaco/overlays/databox.py Outdated
Comment thread chaco/plot.py Outdated
Comment thread chaco/plotscrollbar.py Outdated
Comment thread chaco/scatterplot.py
self.request_redraw()

def _either_metadata_changed(self):
def _either_metadata_updated(self, event):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to confirm, this method was inherited?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, from BaseXYPlot

Co-authored-by: Poruri Sai Rahul <rporuri@enthought.com>
@aaronayres35 aaronayres35 merged commit 25da527 into master Apr 2, 2021
@aaronayres35 aaronayres35 deleted the replace-dynamic-on_trait_change branch April 2, 2021 12:53
@markasbach
Copy link
Copy Markdown
Contributor

If anyone sees this: A typo slipped through with this pull request. I've opened an issue for this: #914

itziakos added a commit that referenced this pull request Oct 11, 2025
 (#915)

As this fixes a typo clearly visible in the source code, I have not
added any code to reproduce the error nor a unit test. Hope this is
still fine (I'm short on time currently, sorry!).

See [Issue 914](#914) and/or
the original pull request #590 that introduced this bug.

Co-authored-by: Ioannis Tziakos <ioannist@enthought.com>
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

Successfully merging this pull request may close these issues.

3 participants