Any way to get list of current Diagram event listeners?

I’m trying to debug a problem where the ChangedSelection event is not called after I swap the model. I know this is not a gojs problem cause I wasn’t able to repro it in an isolated example code. Whatever it is it’s in my code.

Is there an internal property on the diagram that can give me the list of currently registered listeners so I can inspect it?

Sorry, all listener collections are very much kept internally. But I suppose you could try to find it in the debugger. Look at the Diagram.addDiagramListener code to see the minified name of the data member holding the collection.

What you describe is odd. Normally when one constructs and initializes a Diagram, besides setting its properties and templates one declares all of its DiagramEvent listeners, which remain there for the lifetime of the Diagram, no matter how many models it renders.

Perfect. That’s exactly what I wanted. It gets me to a List and that’s what I was looking for. Thanks Walter.

OK OK OK, I think I found what’s going on. The event listener is there and working. No problem with that.

Here’s what’s happening:

When the diagram is rendering modelA for instance, if I click on a node, ChangedSelection event is fired obviously. When I click on the background of the canvas ChangedSelection is again triggered with the selection set being empty.

All good so far, but if I select a node and then change the model to modelB, then clicking on the background of the canvas would not clear the selection.

This looks like a bug to me. What do you think? If you need a repro code let me know and I’ll post it here.

I can see why you might think that to be a bug. We’ll certainly change that behavior for v3.1; I’m not sure if we should make such a change as a bug fix.

It should be easy for you to call Diagram.clearSelection before replacing the Diagram.model.