callbackhell-escape

1.1.1 • Public • Published

callbackhell-escape

The easyest way to escape the callback-hell. I promise you.

Installation

NPM

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.

Package Sidebar

Install

npm i callbackhell-escape

Weekly Downloads

1

Version

1.1.1

License

MIT

Unpacked Size

2.86 kB

Total Files

4

Last publish

Collaborators

  • phyyyl