fix: don't forward undefined

This commit is contained in:
cha0s 2018-12-24 13:21:03 -06:00
parent 75f2e80507
commit f86c2ce89c

View File

@ -34,12 +34,14 @@ export class Dispatcher {
if (debugAction) { if (debugAction) {
debug(`dispatching ${JSON.stringify(debugAction, null, ' ')}`); debug(`dispatching ${JSON.stringify(debugAction, null, ' ')}`);
} }
const actionPromise = actions[action.type](action);
Promise.resolve(actions[action.type](action)).then((result) => { Promise.resolve(actionPromise).then((result) => {
if ('undefined' === typeof result) { if ('undefined' === typeof result) {
debug(`undefined result from ${action.type} not forwarded!`); debug(`undefined result from ${action.type} not forwarded!`);
} }
socket.write(pack(result)); else {
socket.write(pack(result));
}
socket.end(); socket.end();
}).catch((error) => { this.handleError(error); }); }).catch((error) => { this.handleError(error); });
}); });