0.1.1 • Published 4 years ago

just-promise-once v0.1.1

Weekly downloads
22
License
MIT
Repository
github
Last release
4 years ago

Just Promise Once

Do 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!

Installation

npm i just-promise-once

Usage

Socket.io authorization

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);
}

License

Copyright (c) 2020, Michael Szmadzinski. (MIT License)