diff --git a/static/js/app/app.js b/static/js/app/app.js index 5ec641f..a58bc17 100644 --- a/static/js/app/app.js +++ b/static/js/app/app.js @@ -36,6 +36,7 @@ define([ $('#build-console').prev('h2').html('Build #' + buildId + ' console'); $('#build-console').html(''); + connect.resource(resourceName).unsubscribeAll(); connect.resource(resourceName).subscribe(function(data) { $('#build-console').append('
' + data + '
'); }); diff --git a/static/js/dataio.js b/static/js/dataio.js new file mode 100644 index 0000000..9a5556a --- /dev/null +++ b/static/js/dataio.js @@ -0,0 +1,19 @@ +'use strict'; + +define(['_dataio'], function(dataio) { + return function(socket) { + var connect = dataio(socket); + + /* + * Extend resource + */ + var resource = connect.resource('__someResource__'), + resourcePrototype = Object.getPrototypeOf(resource); + + resourcePrototype.unsubscribeAll = function() { + this.socket.removeAllListeners(); + }; + + return connect; + }; +}); \ No newline at end of file diff --git a/static/js/main.js b/static/js/main.js index 8629062..db4c86e 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -5,7 +5,7 @@ require.config({ paths: { underscore: 'libs/underscore/underscore', react: 'libs/react/react-with-addons', - dataio: '/data.io', + _dataio: '/data.io', socketio: '/socket.io/socket.io.js', jquery: 'libs/jquery/jquery' }