zone.api.extensions.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. /**
  9. * Additional `EventTarget` methods added by `Zone.js`.
  10. *
  11. * 1. removeAllListeners, remove all event listeners of the given event name.
  12. * 2. eventListeners, get all event listeners of the given event name.
  13. */
  14. interface EventTarget {
  15. /**
  16. *
  17. * Remove all event listeners by name for this event target.
  18. *
  19. * This method is optional because it may not be available if you use `noop zone` when
  20. * bootstrapping Angular application or disable the `EventTarget` monkey patch by `zone.js`.
  21. *
  22. * If the `eventName` is provided, will remove event listeners of that name.
  23. * If the `eventName` is not provided, will remove all event listeners associated with
  24. * `EventTarget`.
  25. *
  26. * @param eventName the name of the event, such as `click`. This parameter is optional.
  27. */
  28. removeAllListeners?(eventName?: string): void;
  29. /**
  30. *
  31. * Retrieve all event listeners by name.
  32. *
  33. * This method is optional because it may not be available if you use `noop zone` when
  34. * bootstrapping Angular application or disable the `EventTarget` monkey patch by `zone.js`.
  35. *
  36. * If the `eventName` is provided, will return an array of event handlers or event listener
  37. * objects of the given event.
  38. * If the `eventName` is not provided, will return all listeners.
  39. *
  40. * @param eventName the name of the event, such as click. This parameter is optional.
  41. */
  42. eventListeners?(eventName?: string): EventListenerOrEventListenerObject[];
  43. }