Issues with onViewerAdded and onViewerClosed events

onViewerAdded event is sent twice and onViewerClosed is never sent. To reproduce please run the following snippet, and then from the main menu open the Filters viewer (Add->Filters). After that close the Filters by clicking on the x button on the viewer’s toolbar.

let grid = grok.shell.addTableView(grok.data.demo.randomWalk(100, 100)).grid;

let nCallCount = 0;
grok.events.onViewerAdded.subscribe((args) => {
    ++nCallCount;
   console.log("Call Count: " + nCallCount);
});

grok.events.onViewerClosed.subscribe((args) => {
    console.log("Never gets called.");
});

Hi and sorry for delay!
I fixed duplicate events, but can’t now reproduce absent of the onViewerClosed event. Could you reproduce it on dev.datagrok.ai?

I can confirm that onViewerClosed is now called, but both onViewerAdded and onViewerClosed are called 4-5 times each, so the issue doesn’t seem to be fixed.

Dev server wasn’t redeployed, please check it now.

Now both seem to be fixed when a viewer is opened using the main menu, but not when using the JS API in which case none is called.

const viewerFilters = DG.Viewer.filters(dframe);
grok.shell.dockManager.dock(viewerFilters.root, ‘left’, null, ‘Filters’);

1 Like

Ok, I will check it.

These events should not be triggered when you use grok.shell.dockManager.dock(), because it’s a general dock. But they will be triggered if you use TableView.addViewer().