Repository: denoland/deno
File: cli/tsc/dts/lib.deno_web.d.ts (TypeScript)

Code before:
   *     event.preventDefault();
   *   }
   * };
   *
   * // Attach the event listener to a target
   * const target = new EventTarget();
   * target.addEventListener('custom', handleEvent);
   *
   * // Or create a listener inline
   * target.addEventListener('message', (event) => {
   *   console.log('Message received:', event);
   * });
   * ```
   *
   * @category Events
   */
  (evt: Event): void;
}

/**
 * The EventListenerObject interface represents an object that can handle events
 * dispatched by an EventTarget object.
 *
 * This interface provides an alternative to using a function as an event listener.
 * When implementing an object with this interface, the handleEvent() method
 * will be called when the event is triggered.
 *
 * @example
 * ```ts
 * // Creating an object that implements EventListenerObject
 * const myEventListener = {
 *   handleEvent(event) {
 *     console.log(`Event of type ${event.type} occurred`);
 *
 *     // You can use 'this' to access other methods or properties
 *     this.additionalProcessing(event);
 *   },
 *
 *   additionalProcessing(event) {
 *     // Additional event handling logic
 *     console.log('Additional processing for:', event);
 *   }
 * };
 *
 * // Using with any EventTarget (server or client contexts)
 * const target = new EventTarget();
 * target.addEventListener('message', myEventListener);
 *
 * // Later, to remove it:
 * target.removeEventListener('message', myEventListener);
 * ```

Review comment (suggestion):
monospacing

```suggestion
 * The `EventListenerObject` interface represents an object that can handle events
 * dispatched by an `EventTarget` object.
 *
 * This interface provides an alternative to using a function as an event listener.
 * When implementing an object with this interface, the `handleEvent()` method
 * will be called when the event is triggered.
```

Code after:
   *     event.preventDefault();
   *   }
   * };
   *
   * // Attach the event listener to a target
   * const target = new EventTarget();
   * target.addEventListener('custom', handleEvent);
   *
   * // Or create a listener inline
   * target.addEventListener('message', (event) => {
   *   console.log('Message received:', event);
   * });
   * ```
   *
   * @category Events
   */
  (evt: Event): void;
}

/**
 * The `EventListenerObject` interface represents an object that can handle events
 * dispatched by an `EventTarget` object.
 *
 * This interface provides an alternative to using a function as an event listener.
 * When implementing an object with this interface, the `handleEvent()` method
 * will be called when the event is triggered.
 *
 * @example
 * ```ts
 * // Creating an object that implements `EventListenerObject`
 * const myEventListener = {
 *   handleEvent(event) {
 *     console.log(`Event of type ${event.type} occurred`);
 *
 *     // You can use 'this' to access other methods or properties
 *     this.additionalProcessing(event);
 *   },
 *
 *   additionalProcessing(event) {
 *     // Additional event handling logic
 *     console.log('Additional processing for:', event);
 *   }
 * };
 *
 * // Using with any EventTarget (server or client contexts)
 * const target = new EventTarget();
 * target.addEventListener('message', myEventListener);
 *
 * // Later, to remove it:
 * target.removeEventListener('message', myEventListener);
 * ```