I have yet another issue with my gojs-angular 2 upgrade.
Basically I end up with duplicated node in the state (not in the diagram model). I cannot reproduce this issue with the provided sample. However this is what happens with the callstack :
In the provided sample that works :
- ngAfterViewInit in diagram-component.ts is called and inside there is a call to :
// initialize the diagram model with the provided node / link / model data
NgDiagramHelper.initializeModel(this.diagram, this.nodeDataArray, this.linkDataArray, this.modelData);
- inside ng-diagram-helper.ts the model change event is emitted :
component.modelChange.emit(dataChanges);
- in app.component.ts diagramModelChange function is called and the state is “produced” :
public diagramModelChange = function (changes: go.IncrementalData) { ... }
- finally in app.component, the code I was provided with in my previous ticket is called :
this.myDiagramComponent.diagram.delayInitialization(() => {
this.state = produce(this.state, draft => {
draft.diagramNodeData = data.nodeDataArray;
draft.diagramLinkData = data.linkDataArray;
draft.skipsDiagramUpdate = false;
});
});
Now, in my real app, the sequence is different :
- same
- same
- the delayInitialization is called instead of diagramModelChange:
this.myDiagramComponent.diagram.delayInitialization(() => {
this.state = produce(this.state, draft => {
draft.diagramNodeData = data.nodeDataArray;
draft.diagramLinkData = data.linkDataArray;
draft.skipsDiagramUpdate = false;
});
});
4.diagramModelChange is called and the following produces duplicated node :
draft.diagramNodeData = DataSyncService.syncNodeData(changes, draft.diagramNodeData, appComp.observedDiagram.model) as any;
I also notice the following error in the console right after :
Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: ‘[object Object],[object Object],[object Object]’. Current value: ‘[object Object],[object Object],[object Object],[object Object],[object Object]’… Find more at Angular
I have compared my code many times with the sample and I cannot figure out what could possibly be different. Any idea where to look at ?