Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deserialization not working #1005

Open
hanajiffry99 opened this issue May 24, 2023 · 2 comments
Open

Deserialization not working #1005

hanajiffry99 opened this issue May 24, 2023 · 2 comments

Comments

@hanajiffry99
Copy link

I am following the documentation and trying to deserialize the diagram. I have serialized the diagram perfectly and stored it in a json file. During the deserialization process, I retrieve the saved serialized data, parse it and try to deserialize it. Althought I didnt receive any errors its not working. I am using custom nodes, links and ports to create the diagram. This si my code and Looking forward for your support to solve this issue.

const [model, setNewModel] = React.useState(new DiagramModel());

React.useEffect(() => {
    console.log("react initialized");
    window.addEventListener('message', (e) => {
        if (e.data.command === 'serialized') {

            console.log("deserialization code");
            console.log("serialized diagram 1: ", model)
            const parsed = JSON.parse(e.data.data);

            model.deserializeModel(parsed, engine)
            vscode.postMessage({ command: "success_alert", text: 'diagram updated successfully' });
            console.log("serialized diagram 2: ", model)
        }
    });
}, [])
@Alletkla
Copy link

Alletkla commented Aug 3, 2023

What do you mean with "not working"?

Are Nodes/Ports/Links/... missing?

Did you try it with the default implementations?

@kilotone
Copy link

kilotone commented Dec 3, 2023

Are you receiving the event? Can you call json.stringify e.data.data, null, 4
I would suggest wrapping the listener callback in another function , and making sure you remove the event listener when navigating away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants