jerosoler / Drawflow

Simple flow library 🖥️🖱️
https://jerosoler.github.io/Drawflow/
MIT License
4.78k stars 741 forks source link

Any function called in drawflow library when canvas creation is finished with existing data. #612

Closed AnirudhWT closed 1 year ago

jerosoler commented 1 year ago

You can use events to detect.

For example when an import data:

editor.on('import', (import) => {
....
});
AnirudhWT commented 1 year ago

@jerosoler Getting data : Array of objects from some api in angular and using them to map with drawflow.

jerosoler commented 1 year ago

The question is very open.

What kind of data? What do you want to map? If the node already exists? Create more nodes? Modify the nodes? ....

surihoney commented 1 year ago

Hi @jerosoler , what could be wrong if this event not triggered at all ?

editor.on('import', function () {
 console.log("Successfully import");
});
jerosoler commented 1 year ago

@surihoney Is that code before importing?

surihoney commented 1 year ago

i put it after, i tried put it before import also not working, what's the correct order?

`
editor.start();

editor.import(data);

editor.on('import', function () { console.log("Successfully import"); }); `

jerosoler commented 1 year ago

1 start 2 on import event 3 import data

surihoney commented 1 year ago

Still not working, I think maybe because it's inside React component's useEffect maybe it has something to do with that. Thank you for this awesome library .

surihoney commented 1 year ago

Hi this is silly , but what causing the issue I mention above (the import event not triggered) , is because I used the older version of this code. After upgraded, now works flawlessly . @jerosoler