async-ready
async-ready allows you to register async dependencies and be alerted when all of them are ready.
Installation
npm install async-ready
Usage
Pass the module a promise which will be resolved once your dependency is ready.
Say you don't want your server to start listening for connections until a long-running call has completed as part of start-up.
someDependency.js
const asyncReady = ; // register this async dependency as not yet ready (as soon as it's loaded into memory)asyncReady;
app.js
const asyncReady = ; // wait until all async dependencies are loaded before listening for connectionsasyncReady;
Multiple dependencies
You can track as many dependencies as you want. Just register them normally as shown in the example above.