Use once listener as a promise
npm install just-promise-onceDo you need to await on a once event?
Would you like to avoid callbacks in callbacks with your eventlisteners?
Has your socket.io authentication logic gotten out of hand?
Just Promise Once!
npm i just-promise-once
Socket.io authorization
``js
async function socketConnection(socket) {
// Handle authorization first
const [authorization] = await justPromiseOnce(socket, 'authorization', AUTH_TIMEOUT);
await handleAuthorization(authorization);
// Secure protected methods
socket.on('protectedMethod', handleProtectedMethods);
}
``
Copyright (c) 2020, Michael Szmadzinski. (MIT License)