Skip to content

Update file type from lua to luau and split out WhileHasComponents me…#30

Open
Raild3x wants to merge 8 commits intomainfrom
fix/WhileHasComponent
Open

Update file type from lua to luau and split out WhileHasComponents me…#30
Raild3x wants to merge 8 commits intomainfrom
fix/WhileHasComponent

Conversation

@Raild3x
Copy link
Owner

@Raild3x Raild3x commented Sep 24, 2025

This pull request refactors and improves the component lifecycle utility functions in lib/component/src/init.luau. The main focus is to clarify the API by splitting the handling of single and multiple component classes, improving type safety, and updating documentation. It also introduces a new WhileHasComponents method for handling multiple components and updates the deprecated ForEachSibling method for better backward compatibility.

API improvements and refactoring:

  • Split the original WhileHasComponent method into two: WhileHasComponent (for a single component class) and a new WhileHasComponents (for an array of component classes), providing clearer and safer APIs for each use case. [1] [2]
  • Refactored internal logic to ensure that janitors are correctly managed and cleaned up when components start or stop, both for single and multiple component cases.

Documentation and deprecation:

  • Improved documentation for both new methods, including detailed usage examples and clearer descriptions. Fixed a typo in the documentation ("compenent" → "component"). [1] [2]
  • Updated the deprecated ForEachSibling method to warn users to use the new methods and to automatically route calls to the appropriate method for backward compatibility.…thod

@Raild3x Raild3x self-assigned this Sep 24, 2025
Copilot AI review requested due to automatic review settings September 24, 2025 18:50
@Raild3x Raild3x added enhancement New feature or request needs testing labels Sep 24, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request refactors the component lifecycle utility functions by splitting the original WhileHasComponent method into two distinct methods: one for handling single components and another for handling multiple components. This improves type safety and API clarity while maintaining backward compatibility.

  • Split WhileHasComponent into separate methods for single and multiple component handling
  • Added new WhileHasComponents method with improved documentation and examples
  • Updated deprecated ForEachSibling method to automatically route to appropriate methods

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Expanded the Component module with comprehensive documentation covering lifecycle, edge cases, and extension system. Improved robustness for construction and start/stop phases, including cancellation and error handling during yields, rapid reparenting, and memory management. Added internal helper documentation, clarified extension method binding, and enhanced cleanup logic in Destroy. Minor code style and clarity improvements throughout.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 2 changed files in this pull request and generated 8 comments.


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

Enhanced error messages during component construction and added warnings for construction cancellation. Improved validation in WhileHasComponents to ensure all elements are valid component classes. Adjusted cleanup order in Destroy and TryDeconstructComponent to ensure construction locks are always cleared.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 2 changed files in this pull request and generated 8 comments.


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

Rewrote the component construction flow in Component:_instantiate to use a cancellable Promise, improving handling of ancestry changes and construction cancellation. Added detailed phase comments and improved error handling and cleanup logic. Also added and clarified assertions in WhileHasComponent, WhileHasComponents, and ForEachSibling for better API usage validation. Minor doc and formatting improvements throughout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request needs testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants