Add onCallBacks so you can listen to a single callback#32
Conversation
…to register them all
| } | ||
|
|
||
| unregisterCallbacks(implementation: IChatHubCallbacks) { | ||
| this.connection.off('Welcome', implementation.welcome); |
There was a problem hiding this comment.
As i mentioned in other PRs this will not work because "this" in the welcome call will not be "implementation" (I think)
There was a problem hiding this comment.
Ok good point i have reverted my changes for the register and unregister callback methods
There was a problem hiding this comment.
I think we need to internally store the registered lambdas because the off-methods will "dynamically" create new lambda which do not have the same identity (ie not ===) as the registered one and thus they do not unregister anything - or am I wrong?
There was a problem hiding this comment.
I think that the best approach might be to write some unit tests around this topic so we can make sure everything works as intended.
|
Do you think we should merge the changes for the single callbacks in and raise an issue to address the register unregister for the the ICallback implementation. I know the single onCallbacks work because i am using them in my project |
This change will allow a client to listen to a single event callback, instead of having to pass in functions for all options on the Hub.
Also updated the README to reflect this,
And also added the default as Null instead of undefined for typescript as i think null is a better indication than undefined, and aligns with C# more