Skip to content

Conversation

@kevinchappell
Copy link
Collaborator

@kevinchappell kevinchappell commented Nov 5, 2025

ability to pass event handlers through config for common events such as onAdd

resolves #381 #348 #279

ability to pass event handlers through config for common events such as onAdd
Copilot AI review requested due to automatic review settings November 5, 2025 20:52
Copy link
Contributor

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 PR introduces an enhanced component event system that provides a consistent, flexible event handling mechanism for component lifecycle events. The implementation follows a pattern similar to the existing action config in dom.js, allowing developers to configure and respond to various component lifecycle events.

Key Changes:

  • Added comprehensive event system to Component class with addEventListener, removeEventListener, and dispatchComponentEvent methods
  • Integrated event dispatching into lifecycle methods (onAdd, onRemove, addChild, onRender, clone, and data updates)
  • Maintained full backwards compatibility with existing event handlers

Reviewed Changes

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

Show a summary per file
File Description
src/lib/js/components/component.js Core implementation of event system including Map-based event storage, event dispatching, and lifecycle integration
src/lib/js/components/component-events.test.js Test suite covering event initialization, add/remove listeners, dispatching, error handling, and update events
src/lib/js/components/panels.js Added radix parameter to parseInt for proper number parsing
src/lib/js/common/dom.js Removed unused conditions variable from destructuring
src/demo/js/options/enhanced-config-example.js Comprehensive example demonstrating new event system capabilities
src/demo/js/options/config.js Updated to use new event system with enhanced onAdd handler
docs/component-events.md Complete documentation of event system including API reference and migration guide
docs/README.md Added link to component events documentation

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

@kevinchappell kevinchappell added this to the Lifecycle Events milestone Nov 5, 2025
@kevinchappell kevinchappell merged commit bad8e5a into main Nov 5, 2025
2 checks passed
@kevinchappell kevinchappell deleted the feat/component-events branch November 5, 2025 21:28
@kevinchappell
Copy link
Collaborator Author

🎉 This PR is included in version 4.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lifecycle Events revamp

2 participants