Handle the case where no socket.io ack exists

This commit is contained in:
Calvin Montgomery 2017-03-20 22:09:16 -07:00
parent 9dc82ad444
commit 0613083eb0
3 changed files with 43 additions and 0 deletions

11
src/util/ack.js Normal file
View file

@ -0,0 +1,11 @@
export function ackOrErrorMsg(ack, user) {
if (typeof ack === 'function') {
return ack;
}
return (result) => {
if (result.error) {
user.socket.emit('errorMsg', { msg: result.error.message });
}
};
}