Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Extract on SubsetCreateMessage #3238

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
9 changes: 7 additions & 2 deletions jdaviz/core/template_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1539,8 +1539,10 @@ def __init__(self, plugin, items, selected, viewer,
handler=self._on_data_added)
self.hub.subscribe(self, RemoveDataMessage,
handler=lambda _: self._update_items())
# Default Glue subscriber priority is 10, lowest integer priority is handled last
self.hub.subscribe(self, SubsetCreateMessage,
handler=lambda _: self._on_subset_created())
handler=lambda _: self._on_subset_created(),
priority=0)
self.hub.subscribe(self, SubsetUpdateMessage,
handler=lambda _: self._update_items())
self.hub.subscribe(self, SubsetDeleteMessage,
Expand Down Expand Up @@ -2028,6 +2030,8 @@ def __init__(self, plugin, items, selected, multiselect=None, selected_has_subre

self.hub.subscribe(self, SubsetUpdateMessage,
handler=lambda msg: self._update_subset(msg.subset, msg.attribute))
self.hub.subscribe(self, SubsetCreateMessage,
handler=lambda msg: self._update_subset(msg.subset))
Comment on lines +2033 to +2034
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I hoped that I could just replace the trigger for this from SubsetUpdateMessage to SubsetCreateMessage, but it didn't work.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably cannot work as a drop-in replacement since SubsetCreateMessage does not have an attribute (in fact, does nothing). Wondering if this would need something equivalent of LayerSelect._on_subset_created, or if _update_subset can tricked into doing the right action some other way.

self.hub.subscribe(self, SubsetDeleteMessage,
handler=lambda msg: self._delete_subset(msg.subset))
self.hub.subscribe(self, SubsetRenameMessage,
Expand Down Expand Up @@ -2105,7 +2109,8 @@ def _update_subset(self, subset, attribute=None):
self.items = self.items + [self._subset_to_dict(subset)] # noqa
else:
# 'type' can be passed manually rather than coming from SubsetUpdateMessage.attribute
if attribute in ('style', 'type'):
# This will be None if triggered by SubsetCreateMessage
if attribute in ('style', 'type', None):
# TODO: may need to add label and then rebuild the entire list if/when
# we add support for renaming subsets

Expand Down
Loading