8000 fix!: move destroy earlier in the lifecycle by BeksOmega · Pull Request #7117 · google/blockly · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix!: move destroy earlier in the lifecycle #7117

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

Merged
merged 1 commit into from
Jun 1, 2023

Conversation

BeksOmega
Copy link
Collaborator
@BeksOmega BeksOmega commented May 24, 2023

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 #6974

Proposed Changes

Moves the destroy hook call up in the life cycle.

Behavior Before Change

Before the destroy hook was called at the very end of disposal, so it couldn't depend on any of the other state of the block.

Behavior After Change

Now it is called after the block is disconnected from its parent, but before any of its elements or child blocks are disposed. So (e.g.) the destroy hook could depend on the value of the block's fields.

Reason for Changes

If you want to destroy external state that is associated with field values, you need access to the field values in the destroy hook.

Test Coverage

N/A

Documentation

Docs need to be updated for v10.

Additional Information

N/A

Breaking changes / updating / upgrading

If you implement the destroy hook, then note that this hook will now be run before the connections and fields associated with this block are destroyed. This is unlikely to actually require changes in your project unless your destroy hook was explicitly relying on the old timing.

@BeksOmega BeksOmega requested a review from a team as a code owner May 24, 2023 17:26
@BeksOmega BeksOmega requested a review from maribethb May 24, 2023 17:26
@github-actions github-actions bot added breaking change Used to mark a PR or issue that changes our public APIs. PR: fix Fixes a bug and removed PR: fix Fixes a bug breaking change Used to mark a PR or issue that changes our public APIs. labels May 24, 2023
@BeksOmega BeksOmega changed the title fix!: move destroy earlier in the lifcycle fix!: move destroy earlier in the lifecycle May 24, 2023
@github-actions github-actions bot added breaking change Used to mark a PR or issue that changes our public APIs. PR: fix Fixes a bug and removed PR: fix Fixes a bug breaking change Used to mark a PR or issue that changes our public APIs. labels May 24, 2023
Copy link
Contributor
@maribethb maribethb left a comment

Choose a reason for hiding this comment

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

Can you update the PR description in the bottom section you added to be speaking directly to people who view this PR from the release notes? Coming from that mindset, it's not clear what my action item is here. e.g.

If you implement the destroy hook, then note that this hook will now be run before the connections and fields associated with this block are destroyed. This is unlikely to actually require changes in your project unless your destroy hook was explicitly relying on the old timing.

@BeksOmega
Copy link
Collaborator Author

Also @mark-friedman can you check that this timing would work for you?

@mark-friedman
Copy link
Contributor

Also @mark-friedman can you check that this timing would work for you?

I'll check.

@github-actions github-actions bot added breaking change Used to mark a PR or issue that changes our public APIs. PR: fix Fixes a bug and removed PR: fix Fixes a bug breaking change Used to mark a PR or issue that changes our public APIs. labels May 24, 2023
this.inputList.length = 0;
this.getConnections_(true).forEach((c) => c.dispose());
} finally {
eventUtils.enable();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think we need to disable events any longer since the delete event is fired by dispose and not disposeInternal, which is what we use to recurse.

Said another way, only the top level block fires a delete event, so we have no need to disable events for child blocks.

Here is the context for originally disabling events: c429949

@BeksOmega
Copy link
Collaborator Author

I had to move things around to get tests to pass :/ Would you mind doing a re-review @maribethb ? No rush on this though.

@mark-friedman
Copy link
Contributor

Also @mark-friedman can you check that this timing would work for you?

It looks like it would work. Thanks!

@mark-friedman
Copy link
Contributor

Might I also suggest that you change the documentation for the destroy method so that it is clear to the developer that they can count on the block being pretty much intact when their callback is called?

@BeksOmega BeksOmega merged commit 91be84a into google:develop Jun 1, 2023
@BeksOmega BeksOmega deleted the fix/move-destroy branch May 14, 2024 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Used to mark a PR or issue that changes our public APIs. PR: fix Fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move destroy hook to beginning of dispose
3 participants
0