Short Description of the Feature
Create a centralized registry to track all active Toggle instances, enabling debugging, batch operations, and instance management.
Expected Benefits
- Debugging Support: Easy access to all toggles from browser console
- Batch Operations: Perform actions on multiple toggles simultaneously
- Memory Management: Track instance counts and detect leaks
- Analytics: Collect usage statistics across all toggles
- Testing Support: Access instances for integration testing
Acceptance Criteria
Documentation
// Add to window for easy console access
if (typeof window !== 'undefined') {
(window as any).BootstrapToggle = {
Registry: ToggleRegistry,
debug: () => ToggleRegistry.debug(),
stats: () => ToggleRegistry.getStats(),
getAll: () => ToggleRegistry.getAll(),
enableAll: () => ToggleRegistry.enableAll(),
disableAll: () => ToggleRegistry.disableAll()
};
}
// In browser console
BootstrapToggle.debug(); // Show all toggle info
BootstrapToggle.stats(); // Get statistics
BootstrapToggle.getAll(); // List all instances
BootstrapToggle.enableAll(); // Enable all toggles on page
BootstrapToggle.Registry.getByElement(document.getElementById('myToggle')); // Get specific toggle
Additional Comments
- The registry uses WeakMap to avoid preventing garbage collection
- Add a method to find toggles by CSS selector
- Consider adding event tracking for user interactions (optional)
- Include performance warnings when many toggles are active (optional)
- Provide opt-out mechanism for performance-sensitive applications
- Consider adding a method to export toggle states for form serialization
Feature Request Checklist
Short Description of the Feature
Create a centralized registry to track all active Toggle instances, enabling debugging, batch operations, and instance management.
Expected Benefits
Acceptance Criteria
ToggleRegistryclass with static methods for instance managementDocumentation
Additional Comments
Feature Request Checklist