Incremental save diagram

I have two question about incremental save diagram.

1.Model toIncrementalJson(e) method return json. This json object always have a “incremental”: 1 property. it is always 1 ?, if not when become 2 or more. (I know if no change it will be 0)

2.when I load diagram json from web server, and initial my diagram always ModelChanged event was occur. can I ignore it if (evt.oldValue == “Initial Layout”) ?.

The presence of the “incremental” property is to declare that it is not a complete model, and that it has a different set of properties. The value 1 might be used as a version number in the future, but we have no plans on changing the format.

You can ignore all ChangedEvents, unless you need specific events for some purpose.

thank you , I understand question 1. but maybe my explain is bad, question 2, I want sent to server to save incremental json, but every time when I get the json from server initial my diagram ModelChanged event occur. then same json will sent to server again. I want ignore ModelChanged event when initial my diagram, at the first time or reload json from server refresh diagram.

OK, I hope it’s clear that there needs to be ChangedEvents as a result of calling Model.applyIncrementalJson – probably many of them, including Transaction ChangedEvents.

Presumably you know when you are calling that method, so you know to ignore the resulting event that is ChangedEvent.isTransactionFinished.

Now I did not use Model.applyIncrementalJson may be future I use it I don’t know. Now problem is when initial diagram by diagram.model = go.Model.fromJson(jsontxt); the ChangedEvents occur. init diagram when i jump to new page or reload current diagram. ChangedEvents occur is OK. i want know can I ignore first ChangedEvent by this condition if (evt.oldValue == “Initial Layout”) .

I guess that would work.

But why not establish your event handler in an “InitialLayoutCompleted” DiagramEvent listener?

I suppose if you are going to load another model, you’ll want to remove that ChangedEvent handler beforehand.

I already try it, you know, when I reload json again from server I must delete listener and apply it again. and InitialLayoutCompleted itself not occur when reload.

The “InitialLayoutCompleted” DiagramEvent is certainly raised after Diagram.model is replaced.

InitialLayoutCompleted evet occur every time, my fault. but if i use it delete listener and apply it again.
evt.oldValue == “Initial Layout” work very well. well

thank you for everything.

by the way how to remove listener on gojs ?

For every add… method there should be a remove… method.