zone-patch-socket-io.js 1.0 KB

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. /**
  3. * @license Angular v<unknown>
  4. * (c) 2010-2025 Google LLC. https://angular.io/
  5. * License: MIT
  6. */
  7. function patchSocketIo(Zone) {
  8. Zone.__load_patch('socketio', (global, Zone, api) => {
  9. Zone[Zone.__symbol__('socketio')] = function patchSocketIO(io) {
  10. // patch io.Socket.prototype event listener related method
  11. api.patchEventTarget(global, api, [io.Socket.prototype], {
  12. useG: false,
  13. chkDup: false,
  14. rt: true,
  15. diff: (task, delegate) => {
  16. return task.callback === delegate;
  17. },
  18. });
  19. // also patch io.Socket.prototype.on/off/removeListener/removeAllListeners
  20. io.Socket.prototype.on = io.Socket.prototype.addEventListener;
  21. io.Socket.prototype.off =
  22. io.Socket.prototype.removeListener =
  23. io.Socket.prototype.removeAllListeners =
  24. io.Socket.prototype.removeEventListener;
  25. };
  26. });
  27. }
  28. patchSocketIo(Zone);