Prevents memory leaks by tracking all registered event listeners and providing
batch cleanup functionality. Particularly useful for Logic components that need to
register multiple window/document listeners and clean them up on destroy.
Why Use ActionManager?
When adding event listeners in game logic, forgetting to remove them causes memory leaks.
ActionManager tracks all listeners and provides a single removeAll() call for cleanup.
Common Event Targets
window - Global events like resize, blur, focus
document - Keyboard events, pointer events that shouldn't be canvas-bound
destroy() { // Clean up all listeners at once - no memory leaks! this.actions.removeAll(); } }
// Removing individual actions constwheelAction = actions.add(window, 'wheel', onWheel); // ... later ... actions.remove(wheelAction); // Remove just this one
ActionManager - Centralized event listener management utility.
Prevents memory leaks by tracking all registered event listeners and providing batch cleanup functionality. Particularly useful for Logic components that need to register multiple window/document listeners and clean them up on destroy.
Why Use ActionManager?
When adding event listeners in game logic, forgetting to remove them causes memory leaks. ActionManager tracks all listeners and provides a single
removeAll()call for cleanup.Common Event Targets
window- Global events like resize, blur, focusdocument- Keyboard events, pointer events that shouldn't be canvas-boundrenderer.canvas- Canvas-specific eventsCommon Event Types
Example