jdaviz
jdaviz copied to clipboard
[FEAT] Have a way to iterate over viewers not by name
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
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.
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()?
So under the hood, it is a dictionary and thus insertion-ordered. Is this ok?