react-diagrams icon indicating copy to clipboard operation
react-diagrams copied to clipboard

model.deserializeModel should return Promise

Open DanieLazarLDAPPS opened this issue 7 years ago • 0 comments

Hi,

I have one following code snipped

            const model = new DiagramModel();
            // Ignore nextProps.item.diagramModel it is serialized object
            model.deserializeModel(nextProps.item.diagramModel, this.engine);
            this.engine.setModel(model);
            const links = this.engine.getModel().getLinks();
            Object.keys(links).map((key) => {
                // @ts-ignore
                console.log((links[key] as LinkModel).getTargetPort())
            });
            setTimeout(() => {
                Object.keys(links).map((key) => {
                    // @ts-ignore
                    console.log((links[key] as LinkModel).getTargetPort())
                });
            }, 1);

In the first loop, it returns null for function getTargetPort but after one mili timeout it return Port as expected.

I think deserializeModel function should return Promise when everything is set correctly because now source and target ports are null and you have to work around it by setInterval.

DanieLazarLDAPPS avatar Sep 23 '19 11:09 DanieLazarLDAPPS