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

Use registry for creating the no-category flyout #4659

Merged
merged 2 commits into from Mar 1, 2021

Conversation

samelhusseini
Copy link
Contributor

The basics

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

The details

Resolves

Fixes 6 strict missing requires errors.

Proposed Changes

Use the registry for creating the vertical / horizontal flyout on a no-category workspace.

Behavior Before Change

Behavior After Change

Reason for Changes

Test Coverage

Documentation

Additional Information

@rachel-fenichel FYI

throw Error('Missing require for Blockly.HorizontalFlyout');
}
this.flyout_ = new Blockly.HorizontalFlyout(workspaceOptions);
var HorizontalFlyout = Blockly.registry.getClassFromOptions(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This no longer throws a clear error for the missing require. Are we okay with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That’s true, so it’s not exactly the right check to check if Blockly.HorizontalFlyout exists any more since it can be some other object that is registered, but we can check if getClassFromOptions returns nothing and throw.
I would rather deal with this in the registry. It is currently logging a warning. This sounds like something that applies anywhere we request a class from the registry (the whole warn vs throw dilemma). If we want to throw or warn on a case by case basis then we can add another param to the registry call to request a throw if it yields nothing. I would just rather not have to always check if exists and throw.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I like having it optionally throw on failure. At the call site we often know whether a failure would be catastrophic--like here--and a centralized throw would be way better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I’ll add that functionality to the registry, and make it throw from this call site

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@samelhusseini samelhusseini merged commit 5780399 into google:develop Mar 1, 2021
@samelhusseini samelhusseini deleted the use_flyout_registry branch March 1, 2021 18:00
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

3 participants