Update file type from lua to luau and split out WhileHasComponents me…#30
Update file type from lua to luau and split out WhileHasComponents me…#30
Conversation
There was a problem hiding this comment.
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
WhileHasComponentinto separate methods for single and multiple component handling - Added new
WhileHasComponentsmethod with improved documentation and examples - Updated deprecated
ForEachSiblingmethod 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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 newWhileHasComponentsmethod for handling multiple components and updates the deprecatedForEachSiblingmethod for better backward compatibility.API improvements and refactoring:
WhileHasComponentmethod into two:WhileHasComponent(for a single component class) and a newWhileHasComponents(for an array of component classes), providing clearer and safer APIs for each use case. [1] [2]Documentation and deprecation:
ForEachSiblingmethod to warn users to use the new methods and to automatically route calls to the appropriate method for backward compatibility.…thod