Developers sometimes want to run some actions after a workspace finishes loading. There is no event to indicate this right now.
A new type of event, finishedLoading, is fired at the end of Blockly.Xml.domToWorkspace.
No event is fired.
Another option is to include a flag on block creation events that indicates whether the event was fired while loading a workspace. This would help if developers are doing validation as each event comes in and want to respond differently depending on whether or not the workspace has been fully loaded.
I have a free(ish) week comming up so I wanted to take a look at this, but I'm not sure how hard-core to go. I could:
A) Do the easy thing and create a simple FINISHED_LOADING event that just notifies the developer when domToWorkspace() is finished and that's it.
C) Do the other easy thing and add a "onLoad" flag to the block creation events.
or B) Do the fun thing and create a WORKSPACE_LOAD event with undo and redo for the domToWorkspace() call & possibly a WorkspaceBase event incase you ever want to add more workspace events in the future.
Is there an option you would prefer?
Let's go with the simple solution (A). If we see more demand for it we can do the others later. Thanks!
From BeksOmega via #2250 :
I was doing some poking around in the events files working on a different issue, and I noticed the Blockly.Events.fromJson function. Would it make sense for the FinishedLoading event to be added to this? I wasn't sure since the FinishedLoading event is basically a notification about a specific workspace, and the fromJson function takes in a workspace that is then "applied" to the event.
In general, we're aiming to have high level APIs create and fire events. I think having the Events API fire additional events in response to things can make ownership of the events and defining which layer does what get messy quickly. I'd prefer to keep the responsibility for events in the API that's taking the action (eg, domToWorkspace() fires the event).