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

Added FinishedLoading Event #2235

Merged
merged 5 commits into from Jan 28, 2019

Conversation

BeksOmega
Copy link
Collaborator

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide

The details

Resolves

Proposed Changes

#2142

Reason for Changes

Quote from Issue:

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

Test Coverage

1 . Turned on "Log events" in the playground.
2 . Hit the "Spaghetti" button.
3 . Observed how a FinishedLoading event was correctly fired. (pass)

1 . Changed the following code ~ln 251 in playground:

  console.time('Spaghetti domToWorkspace');
  Blockly.Xml.domToWorkspace(dom, workspace);
  console.timeEnd('Spaghetti domToWorkspace');

To:

 console.time('Spaghetti domToWorkspace');
 Blockly.Events.setGroup(true);
 console.log(Blockly.Events.group_);
 Blockly.Xml.domToWorkspace(dom, workspace);
 Blockly.Events.setGroup(false);
 console.timeEnd('Spaghetti domToWorkspace');

2 . Hit the "Spaghetti" button.
3 . Observed how a FinishedLoading event (with the correct group) was fired. (pass)

1 . Added the following code at ~ln 256 in playground (at the top of the spaghettiXml var):
' <shadow type="controsl_if"></shadow>',
2 . Hit the "Spaghetti" button.
3 . Observed how the FinishedLoading event was not fired, because an error was thrown. (pass)

Tested on:

  • Desktop Chrome

Additional Information

I'm not sure the FinishedLoading event needed to be in a new file, but I couldn't decide where else to put it. If it does need to be in a new file, I'm not sure if the copyright should be updated to 2019 or not.

@@ -467,6 +467,7 @@ Blockly.Xml.domToWorkspace = function(xml, workspace) {
if (workspace.setResizesEnabled) {
workspace.setResizesEnabled(true);
}
Blockly.Events.fire(new Blockly.Events.FinishedLoading(workspace));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a goog.require for Blockly.Events.FinishedLoading at the top of this file.

* Encode the event as JSON.
* @return {!Object} JSON representation.
*/
Blockly.Events.Ui.prototype.toJson = function() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this and line 88 to be Blockly.Events.FinishedLoading instead of Blockly.Events.Ui

@BeksOmega BeksOmega changed the title Feature/finished loading Added FinishedLoading Event Jan 28, 2019
@rachel-fenichel rachel-fenichel merged commit b7fc1f8 into google:develop Jan 28, 2019
@BeksOmega BeksOmega deleted the feature/FinishedLoading branch January 29, 2019 14:58
@rachel-fenichel rachel-fenichel mentioned this pull request Feb 12, 2019
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

Successfully merging this pull request may close these issues.

None yet

2 participants