toIncrementalData method

IncrementalData toIncrementalData(
  1. ChangedEvent e
)

Produce an object representing the changes in the most recent Transaction. The structure of the object follows the same format as the JSON output from #toIncrementalJson.

Note that these incremental changes include the results of undo and redo operations.

For GraphLinksModels, this method requires that GraphLinksModel#linkKeyProperty is not an empty string.

Any node or link data objects contained in the "modified..." properties will be deep copies of the data in the model. The objects will contain proper copies of certain GoJS classes, and some common built-in objects such as Dates and RegExps. Other classes will just be copied as plain Javascript objects, so it is best to avoid using special classes in one's data.

This method is most commonly used when GoJS must communicate with some external data source and maintain integrity between the two while avoiding serialization/deserialization.

  myDiagram.addModelChangedListener(e => {
    if (e.isTransactionFinished) {
      var dataChanges = e.model.toIncrementalData(e);
      ... update React state/save to database ...
    }
  });

Caution: don't call JSON.stringify on the resulting object, because that will not properly handle any instances of JavaScript classes that are referenced by the object's properties. Instead call #toIncrementalJson, which will produce a more compact textual serialization. @param {ChangedEvent} e a Transaction ChangedEvent for which ChangedEvent#isTransactionFinished is true @return {IncrementalData} returns either null if no changes occurred, or an object containing incremental model changes for the given Transaction @see #toIncrementalJson @since 2.1

Implementation

_i3.IncrementalData toIncrementalData(_i3.ChangedEvent e) => _i4.callMethod(
      this,
      'toIncrementalData',
      [e],
    );