-
Notifications
You must be signed in to change notification settings - Fork 599
sendTypingIndicator: make callback optional #457
Conversation
Is this behaviour consistent with code you're seeing elsewhere in the api? I don't think I understand why we would want to allow people to pass in objects or other types that get silently swapped for an empty callback. |
Ahh sorry, I reread the example and see what you were trying to do. Not sure what the right option is here. More of a design question at this point. |
how about adding some warning when swapping for an empty callback? |
Ok sure. I talked to @bsansouci and he thought this is a usecase worth supporting. Let's go with the warning rather than failing. |
ea8d6ff
to
adb280f
Compare
Is everything okey now? |
src/sendTypingIndicator.js
Outdated
return function end(cb) { | ||
makeTypingIndicator(false, threadID, cb || function() {}); | ||
if(!callback || (utils.getType(threadID) !== 'Function' && utils.getType(threadID) !== 'AsyncFunction')) { | ||
cb = () => {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warning here like above? Also I don't know why you're checking !callback
and threadID
instead of cb
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh god... I should get more sleep 😆
Added warning when there is a `callback` but it is not a function.
Thanks. |
Added warning when there is a `callback` but it is not a function.
I was getting this error:
when using:
and it turned out that
function end(cb)
was called withcb
being an object instead of a function.