callbackhell-escape
v1.1.1
Published
The easyest way to escape the callback-hell. I promise you.
Downloads
13
Maintainers
Readme
callbackhell-escape
The easyest way to escape the callback-hell. I promise you.
Installation
Usage
const Blocker = require("callbackhell-escape")
// set up a new blocker
let b = new Blocker()
// call a asynchronous function
setTimeout(function() {
console.log("callback after 1 second")
// release the blocker at the end of the callback
b.release()
}, 1000);
//normal codeflow continues
console.log("not synchronized")
// blocking until release() is called
b.wait()
console.log("synchronized")
The Blocker can be (re)activated afterwards:
b.block()
So you can use one blocker to execute multiple asynchronous functions in a single synchronous codeflow.