callbackhell-escape

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

Usage no npm install needed!

<script type="module">
  import callbackhellEscape from 'https://cdn.skypack.dev/callbackhell-escape';
</script>

README

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.