Skip to content

refactor(components): standardize beforeremove handler naming#8882

Merged
willeastcott merged 1 commit into
mainfrom
refactor/onbeforeremove-naming
Jun 11, 2026
Merged

refactor(components): standardize beforeremove handler naming#8882
willeastcott merged 1 commit into
mainfrom
refactor/onbeforeremove-naming

Conversation

@willeastcott

Copy link
Copy Markdown
Contributor

Summary

Fifth and final PR in the component-consistency series (follows #8878, #8879, #8880, #8881).

The system method bound to the beforeremove event was named five different ways across the 20 component systems that bind it:

Old name Systems
onBeforeRemove (kept) camera, sound, animation, anim, rigid-body, collision, sprite, particle-system
_onRemoveComponent light, button, scroll-view, scrollbar, layout-group
onRemove model, render, gsplat
onRemoveComponent screen, element
_onBeforeRemove zone, script

All are now onBeforeRemove, matching the majority convention. Rename-only — every binding and method body is otherwise unchanged.

Deliberately untouched:

  • Component-side methods the handlers call (component.onRemove(), component._onBeforeRemove()) — only the system methods are renamed.
  • Collision's onRemove — it is bound to the distinct remove event, not beforeremove, so its name already follows the convention.
  • The _onBeforeRemove entry in script/constants.js — that is the reserved component-side script instance method, not the system handler.

Also removes a redundant this.app = app assignment from JointComponentSystem (the base ComponentSystem constructor already sets it).

Verified no references to the old names remain anywhere in src/, test/, or examples/ (these were undocumented internals with no external call sites).

Testing

  • Full npm test suite passes (1817 passing), no test edits needed
  • ESLint clean on all 13 changed files

🤖 Generated with Claude Code

The system method bound to the beforeremove event was named five
different ways across component systems (onBeforeRemove, onRemove,
_onRemoveComponent, onRemoveComponent, _onBeforeRemove). Rename all of
them to onBeforeRemove, matching the majority convention already used
by camera, sound, animation, anim, rigid-body, collision, sprite and
particle-system.

Component-side methods (component.onRemove, component._onBeforeRemove)
are untouched, as is collision''s separate onRemove handler which is
bound to the distinct remove event.

Also removes a redundant this.app assignment from JointComponentSystem
(the base ComponentSystem constructor already sets it).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@willeastcott willeastcott requested a review from Copilot June 11, 2026 19:46
@willeastcott willeastcott self-assigned this Jun 11, 2026
@willeastcott willeastcott added the enhancement Request for a new feature label Jun 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR standardizes the naming of component system handlers bound to the beforeremove event by renaming them to onBeforeRemove across the remaining inconsistent systems, aligning with the majority convention in src/framework/components. It also removes a redundant this.app = app assignment from JointComponentSystem since the base ComponentSystem constructor already sets it.

Changes:

  • Renamed various beforeremove system handlers (_onRemoveComponent, onRemove, onRemoveComponent, _onBeforeRemove) to onBeforeRemove (bindings + method definitions).
  • Kept handler behavior unchanged (method bodies remain the same; only system method names changed).
  • Removed redundant this.app = app assignment in JointComponentSystem.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/framework/components/button/system.js Rename beforeremove handler to onBeforeRemove.
src/framework/components/element/system.js Rename beforeremove handler to onBeforeRemove.
src/framework/components/gsplat/system.js Rename beforeremove handler from onRemove to onBeforeRemove.
src/framework/components/joint/system.js Remove redundant this.app = app assignment (already set by base class).
src/framework/components/layout-group/system.js Rename beforeremove handler to onBeforeRemove.
src/framework/components/light/system.js Rename beforeremove handler to onBeforeRemove.
src/framework/components/model/system.js Rename beforeremove handler from onRemove to onBeforeRemove.
src/framework/components/render/system.js Rename beforeremove handler from onRemove to onBeforeRemove.
src/framework/components/screen/system.js Rename beforeremove handler from onRemoveComponent to onBeforeRemove.
src/framework/components/script/system.js Rename beforeremove handler to onBeforeRemove.
src/framework/components/scroll-view/system.js Rename beforeremove handler to onBeforeRemove.
src/framework/components/scrollbar/system.js Rename beforeremove handler to onBeforeRemove.
src/framework/components/zone/system.js Rename beforeremove handler from _onBeforeRemove to onBeforeRemove.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@willeastcott willeastcott merged commit c3e558f into main Jun 11, 2026
10 checks passed
@willeastcott willeastcott deleted the refactor/onbeforeremove-naming branch June 11, 2026 19:49
willeastcott added a commit that referenced this pull request Jun 12, 2026
…reRemove (#8885)

PR #8882 standardized the system-side 'beforeremove' handler name to
onBeforeRemove. This completes the standardization on the component
side, where the teardown method invoked by that handler was still
named inconsistently:

- onRemove() -> onBeforeRemove() in button, camera, element, gsplat,
  layout-group, light, model, render, screen, scroll-view, scrollbar
  and sound
- _onBeforeRemove() -> onBeforeRemove() in zone, script and joint
- onDestroy() -> onBeforeRemove() in sprite

The collision system's own system-level onRemove (bound to the
distinct 'remove' event) is intentionally unchanged.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Request for a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants