mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-19 05:03:32 +08:00
Merge pull request #8351 from AkosLukacs/patch-1
SignalR HubProxy.on() and HubProxy.off() should accept the same parameters, since you unsubscribe the same method...
This commit is contained in:
@@ -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());
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
2
signalr/signalr.d.ts
vendored
2
signalr/signalr.d.ts
vendored
@@ -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<any>;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user