# addApplicationListener abstract method

Future<void> addApplicationListener(

1. ApplicationEventListener<ApplicationEvent> listener

)

Adds an ApplicationEventListener to be notified of all ApplicationEvents.

Event listeners receive all application events published through the context's event system, enabling reactive programming patterns and loose coupling.

### Listener Registration:

- Listeners are typically registered before context refresh
- Can be added dynamically at runtime
- Receive events in registration order (unless ordered)
- Automatically removed when context is closed

### Example:

    class PerformanceMonitor implements ApplicationEventListener<ApplicationEvent> {
      @override
      void onApplicationEvent(ApplicationEvent event) {
        // Monitor all application events
        metrics.increment('application.events.${event.runtimeType}');
      }
    }

    class DomainEventListener implements ApplicationEventListener<UserCreatedEvent> {
      @override
      void onApplicationEvent(UserCreatedEvent event) {
        // React to specific domain events
        analytics.trackUserCreation(event.user);
      }
    }

    // Registration
    context.addApplicationListener(PerformanceMonitor());
    context.addApplicationListener(DomainEventListener());

### Ordering and Filtering:

Listeners can implement Ordered or use `@Order` annotation to control execution order. For type-specific handling, implement the generic ApplicationEventListener interface.

## Implementation

    Future<void> addApplicationListener(ApplicationEventListener listener);