model.addChangedListener behavior

In the following code, the model is changed, plus a model.addChangedListener is being registered to detect any subsequent changes made by user actions.

I want the callback function, myModelChanged to be invoked only on subsequent changes, and not when the whole model is changed. I have tried using a flag newModel = true for the purpose, turning it to false after a new model has been created.

However, the callback method is invoked in both situations, when the new model is created, and when it is changed by user actions.

var newModel = true;

function diagChange(nodes, links) {
  diagram.model = new go.GraphLinksModel(nodes, links);
  newModel = false;
  diagram.model.addChangedListener(function (e) {
      if (!newModel && e.isTransactionFinished) {

How can I make sure that the callback is called only with the subsequent changes to the model?

Can you add the Changed listener only when you are interested in starting to receive such notifications?