WorkboxEventTarget.d.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { WorkboxEvent, WorkboxEventMap } from './WorkboxEvent.js';
  2. export declare type ListenerCallback = (event: WorkboxEvent<any>) => any;
  3. /**
  4. * A minimal `EventTarget` shim.
  5. * This is necessary because not all browsers support constructable
  6. * `EventTarget`, so using a real `EventTarget` will error.
  7. * @private
  8. */
  9. export declare class WorkboxEventTarget {
  10. private readonly _eventListenerRegistry;
  11. /**
  12. * @param {string} type
  13. * @param {Function} listener
  14. * @private
  15. */
  16. addEventListener<K extends keyof WorkboxEventMap>(type: K, listener: (event: WorkboxEventMap[K]) => any): void;
  17. /**
  18. * @param {string} type
  19. * @param {Function} listener
  20. * @private
  21. */
  22. removeEventListener<K extends keyof WorkboxEventMap>(type: K, listener: (event: WorkboxEventMap[K]) => any): void;
  23. /**
  24. * @param {Object} event
  25. * @private
  26. */
  27. dispatchEvent(event: WorkboxEvent<any>): void;
  28. /**
  29. * Returns a Set of listeners associated with the passed event type.
  30. * If no handlers have been registered, an empty Set is returned.
  31. *
  32. * @param {string} type The event type.
  33. * @return {Set<ListenerCallback>} An array of handler functions.
  34. * @private
  35. */
  36. private _getEventListenersByType;
  37. }