Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Procedure Serialization

31 views
Skip to first unread message

Joshua Lowe

unread,
Feb 6, 2025, 5:07:52 PMFeb 6
to Blockly
Hi all,

I'm using the @blockly/block-shareable-procedures package and Blockly 11.2.1 to create custom procedure blocks. Everything works up until the point I serialize the workspace and load it back in.

I'm adding new procedure models with the following code within my custom function definition block: 

this.model = new ObservableProcedureModel(this.workspace, "my_function");
this.workspace.getProcedureMap().add(this.model);

Loading the serialized state fails because Blockly is trying to reference a procedure id, however it does not exist in the serialization. It seems only the blocks get serialized.

Is there an extra step I am missing in order to include procedures within the serialization? 

Thanks!

Joshua Lowe

unread,
Feb 6, 2025, 5:29:19 PMFeb 6
to Blockly
Forgot to add in my initial post that I'm serializing the entire workspace via:

Blockly.serialization.workspaces.save(workspace)

Which as far as I understood, should include everything, including procedures.

Mark Friedman

unread,
Feb 6, 2025, 6:01:11 PMFeb 6
to blo...@googlegroups.com
I might be missing something, but it looks like you need to explicitly call registerProcedureSerializer(), which you can import from the @blockly/block-shareable-procedures package.  That should probably be mentioned on the Using procedure blocks page in the documentation.

-Mark


--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/blockly/7ccd7429-155b-4f5d-bcb7-dfca215d08d3n%40googlegroups.com.

Joshua Lowe

unread,
Feb 6, 2025, 6:10:14 PMFeb 6
to Blockly
Exactly what I was looking for, thanks Mark! My bad for not looking through the exports, as I probably could have found that from the comment attached to the function 😂

Definitely would help to have this mentioned in the docs.

Reply all
Reply to author
Forward
0 new messages