socket-io.ts 960 B

123456789101112131415161718192021222324
  1. /**
  2. * @license
  3. * Copyright Google Inc. 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. Zone.__load_patch('socketio', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
  9. (Zone as any)[Zone.__symbol__('socketio')] = function patchSocketIO(io: any) {
  10. // patch io.Socket.prototype event listener related method
  11. api.patchEventTarget(global, [io.Socket.prototype], {
  12. useG: false,
  13. chkDup: false,
  14. rt: true,
  15. diff: (task: any, delegate: any) => {
  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 = io.Socket.prototype.removeListener =
  22. io.Socket.prototype.removeAllListeners = io.Socket.prototype.removeEventListener;
  23. };
  24. });