zone-patch-socket-io.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. (function (global, factory) {
  9. typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
  10. typeof define === 'function' && define.amd ? define(factory) :
  11. (factory());
  12. }(this, (function () { 'use strict';
  13. /**
  14. * @license
  15. * Copyright Google Inc. All Rights Reserved.
  16. *
  17. * Use of this source code is governed by an MIT-style license that can be
  18. * found in the LICENSE file at https://angular.io/license
  19. */
  20. Zone.__load_patch('socketio', function (global, Zone, api) {
  21. Zone[Zone.__symbol__('socketio')] = function patchSocketIO(io) {
  22. // patch io.Socket.prototype event listener related method
  23. api.patchEventTarget(global, [io.Socket.prototype], {
  24. useG: false,
  25. chkDup: false,
  26. rt: true,
  27. diff: function (task, delegate) {
  28. return task.callback === delegate;
  29. }
  30. });
  31. // also patch io.Socket.prototype.on/off/removeListener/removeAllListeners
  32. io.Socket.prototype.on = io.Socket.prototype.addEventListener;
  33. io.Socket.prototype.off = io.Socket.prototype.removeListener =
  34. io.Socket.prototype.removeAllListeners = io.Socket.prototype.removeEventListener;
  35. };
  36. });
  37. })));