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

feat: refactor event serialization to use static fromJson method #6614

Merged
merged 10 commits into from
Nov 14, 2022

Conversation

BeksOmega
Copy link
Collaborator

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide
  • I ran npm run format and npm run lint

The details

Resolves

Fixes #6607

Proposed Changes

Adds a new path to Blockly.Events.fromJson which uses a static fromJson method on the event classes to deserialize them.

Also adds static fromJson methods to all existing events.

Reason for Changes

See #6607

Test Coverage

Adds round-trip serialization tests for all events, and updates change detectors in places where serialization was previously broken.

Documentation

N/A

Additional Information

I've marked the static fromJson methods as @internal since I'm not super hapy with the types, and external devs should be calling Blockly.Events.fromJson anyway.

@BeksOmega BeksOmega requested a review from a team as a code owner November 11, 2022 17:34
@github-actions github-actions bot added the PR: feature Adds a feature label Nov 11, 2022
@@ -32,7 +34,7 @@ export class BlockBase extends AbstractEvent {
*/
constructor(opt_block?: Block) {
super();
this.isBlank = !!opt_block;
this.isBlank = !opt_block;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have a comment about this property?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Like what isBlank means?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. Like the comments below regarding the other properties.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It has a docs comment here, do you think that's sufficient? I don't necessarily want to duplicate docs that might go out-of-date.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, cool. Agreed, don't want to duplicate comments.

That said, that comment looks like Copilot wrote it. X.isY -> "Whether or not X is Y" 🙄 I still have no idea what a 'blank' event means.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated. How's that feel?

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome!

@BeksOmega BeksOmega merged commit f64c934 into google:develop Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: feature Adds a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor event serialization
2 participants