I have a problem with handling the response of my async function in socket.io.
This is the main function, that I am dealing with.
return self.loadFiles()
.then(resolve)
.catch(reject)
.then(_ => {
socket.emit('RESPONSE', 'socketEmitResponse')
})
loadFiles and serveFiles are both asyncFunctions. The Promise will eventually resolve here:
postAuthenticate : (socket) => {
socket.on('syncEvent', function(data, callback) {
return sync.syncThis(data)
.catch(errorHandler)
.then(callback('socketCallback'))
})
}
Currently the response looks something like this:
> socketEmitResponse
> socketCallback
What I want is that the callback will execute first and then the emitResponse. How can I achieve that?
via Leonard Eyer
No comments:
Post a Comment