jdaviz icon indicating copy to clipboard operation
jdaviz copied to clipboard

[FEAT] Have a way to iterate over viewers not by name

Open eteq opened this issue 2 years ago • 3 comments
trafficstars

Jdaviz component

Imviz

What is the problem this feature will solve?

It's mildly annoying to have to do:

for viewer_name in imviz.app.get_viewer_reference_name():
    viewer = imviz.app.get_viewier(viewer_name)
    ... do something with each viewer ...

because it requires extra API calls for something that is pretty fundamental: doing an action automatically on each viewer.

Describe the desired outcome

It would be nice to have:

for viewer in imviz.app.get_viewers():
    ... do something with each viewer ...

which would behave exactly the same as the above. Even better if it's imviz.get_viewers() since I think this is a convenience feature for some pretty standard use cases.

Additional context

🐱

eteq avatar Jul 31 '23 15:07 eteq

This already exists (although not public) as for viewer_ref, viewer in imviz.app._viewer_store.items(), so should be pretty easy to expose at a higher-level once we decide on exact syntax, etc.

kecnry avatar Jul 31 '23 16:07 kecnry

Oh, I didn't know that! Yeah, then maybe that just needs to be upgraded to a more useful public API name like imviz.get_viewers or imviz.app.get_viewers(), and the implementation is just return imviz.app._viewer_store.items()?

eteq avatar Jul 31 '23 17:07 eteq

So under the hood, it is a dictionary and thus insertion-ordered. Is this ok?

pllim avatar Aug 01 '23 23:08 pllim