Skip to content

Commit

Permalink
fix callbacks undefined bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Siyuan Zheng committed Aug 3, 2017
1 parent f45ba04 commit 279ee9a
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/Hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,18 @@ export class HubConnection extends Connection{
}

clearInvocationCallbacks(error?:Error){
let errorCallbacks = Array<(r:HubResult)=>void>()
var callbackArray = Object.keys(this.callbacks).forEach(key=>{
errorCallbacks.push(this.callbacks[key]);
this.callbacks[key] = null;
});
this.callbacks = null;
let hubRes = new HubResult();
error = error || new Error("need clear invocation callbacks");
hubRes.E = error.message;
errorCallbacks.forEach(errorCallback=>errorCallback(hubRes))
if(this.callbacks){
let errorCallbacks = Array<(r:HubResult)=>void>();
var callbackArray = Object.keys(this.callbacks).forEach(key=>{
errorCallbacks.push(this.callbacks[key]);
this.callbacks[key] = null;
});
this.callbacks = null;
let hubRes = new HubResult();
error = error || new Error("need clear invocation callbacks");
hubRes.E = error.message;
errorCallbacks.forEach(errorCallback=>errorCallback(hubRes));
}
}

onSending():string{
Expand Down

0 comments on commit 279ee9a

Please sign in to comment.