From 786f2c322a1480bd9197c2f3be88c5edf6991d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81kos=20Luk=C3=A1cs?= Date: Wed, 2 Mar 2016 15:34:12 +0100 Subject: [PATCH 1/2] Update signalr.d.ts HubProxy.on() and HubProxy.off() should accept the same parameters, since you unsubscribe the same method... --- signalr/signalr.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/signalr/signalr.d.ts b/signalr/signalr.d.ts index d899416dd3..749277a40c 100644 --- a/signalr/signalr.d.ts +++ b/signalr/signalr.d.ts @@ -77,7 +77,7 @@ interface HubProxy { init(connection: HubConnection, hubName: string): void; hasSubscriptions(): boolean; on(eventName: string, callback: (...msg: any[]) => void ): HubProxy; - off(eventName: string, callback: (msg: any) => void ): HubProxy; + off(eventName: string, callback: (...msg: any[]) => void ): HubProxy; invoke(methodName: string, ...args: any[]): JQueryDeferred; } From 7012659e6f67f063a67b9a3bffa7ec7e430b47d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81kos=20Luk=C3=A1cs?= Date: Wed, 2 Mar 2016 15:42:36 +0100 Subject: [PATCH 2/2] Update signalr-tests.ts Test for unsubscribing a listener with more than 1 parameter --- signalr/signalr-tests.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/signalr/signalr-tests.ts b/signalr/signalr-tests.ts index 5c79f82702..5f2136780b 100644 --- a/signalr/signalr-tests.ts +++ b/signalr/signalr-tests.ts @@ -113,8 +113,19 @@ function test_hubs() { proxy.on('addMessage', function (msg?) { console.log(msg); }); + + //a listener may have more than 1 parameter, and you should be able to subscribe and unsubscribe + function listenerWithMoreParams(id: number, anything: string){ + console.log('listenerWithMoreParams -> ', arguments); + }; + //subscribe + proxy.on('listenerWithMoreParams', listenerWithMoreParams); + var connection = $.hubConnection('http://localhost:8081/'); connection.start({ jsonp: true }); + + //unsubscribe + proxy.off('listenerWithMoreParams', listenerWithMoreParams); } // Sample from : https://github.com/SignalR/SignalR/wiki/QuickStart-Hubs#javascript--html @@ -134,4 +145,4 @@ $(function () { chat.server.send($('#msg').val()); }); }); -}); \ No newline at end of file +});