add unsubscribe method to client resource

This commit is contained in:
oleg 2015-05-06 01:39:58 +03:00
parent 12d56926e5
commit 004b482a06
3 changed files with 21 additions and 1 deletions

View File

@ -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('<div>' + data + '</div>');
});

19
static/js/dataio.js Normal file
View File

@ -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;
};
});

View File

@ -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'
}