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

Add finishedLoading event #2142

Closed
rachel-fenichel opened this issue Nov 28, 2018 · 4 comments
Closed

Add finishedLoading event #2142

rachel-fenichel opened this issue Nov 28, 2018 · 4 comments
Labels
component: developer apis component: events help wanted External contributions actively solicited issue: feature request Describes a new feature and why it should be added

Comments

@rachel-fenichel
Copy link
Collaborator

Problem statement

Developers sometimes want to run some actions after a workspace finishes loading. There is no event to indicate this right now.

Expected Behavior

A new type of event, finishedLoading, is fired at the end of Blockly.Xml.domToWorkspace.

Actual Behavior

No event is fired.

Additional Information

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.

@BeksOmega
Copy link
Collaborator

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?

@rachel-fenichel
Copy link
Collaborator Author

Let's go with the simple solution (A). If we see more demand for it we can do the others later. Thanks!

@RoboErikG
Copy link
Contributor

RoboErikG commented Feb 5, 2019

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.

@RoboErikG
Copy link
Contributor

RoboErikG commented Feb 5, 2019

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: developer apis component: events help wanted External contributions actively solicited issue: feature request Describes a new feature and why it should be added
Projects
None yet
Development

No branches or pull requests

3 participants