Skip to content

Commit

Permalink
feat(patch): fix angular#828, patch socket.io client
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaLiPassion committed Jan 16, 2018
1 parent fd91152 commit 0119f16
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ gulp.task('build/zone-patch-user-media.min.js', ['compile-esm'], function(cb) {
return generateScript('./lib/browser/webapis-user-media.ts', 'zone-patch-user-media.min.js', true, cb);
});

gulp.task('build/zone-patch-socket-io.js', ['compile-esm'], function(cb) {
return generateScript('./lib/extra/socket-io.ts', 'zone-patch-socket-io.js', false, cb);
});

gulp.task('build/zone-patch-socket-io.min.js', ['compile-esm'], function(cb) {
return generateScript('./lib/extra/socket-io.ts', 'zone-patch-socket-io.min.js', true, cb);
});

gulp.task('build/bluebird.js', ['compile-esm'], function(cb) {
return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.js', false, cb);
});
Expand Down Expand Up @@ -297,6 +305,8 @@ gulp.task('build', [
'build/zone-patch-electron.min.js',
'build/zone-patch-user-media.js',
'build/zone-patch-user-media.min.js',
'build/zone-patch-socket-io.js',
'build/zone-patch-socket-io.min.js',
'build/zone-mix.js',
'build/bluebird.js',
'build/bluebird.min.js',
Expand Down
24 changes: 24 additions & 0 deletions lib/extra/socket-io.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
Zone.__load_patch('socketio', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
(Zone as any)[Zone.__symbol__('socketio')] = function patchSocketIO(io: any) {
// io is being mixed with Emitter.prototype, so we can patchEventTargetMethods
// with io.prototype
api.patchEventTarget(global, [io.Socket.prototype], {
useG: false,
chkDup: false,
rt: true,
diff: (task: any, delegate: any) => {
return task.callback === delegate;
}
});
io.Socket.prototype.on = io.Socket.prototype.addEventListener;
io.Socket.prototype.off = io.Socket.prototype.removeListener =
io.Socket.prototype.removeAllListeners = io.Socket.prototype.removeEventListener;
};
});

0 comments on commit 0119f16

Please sign in to comment.