Skip to content

Latest commit

 

History

History
29 lines (20 loc) · 864 Bytes

README.md

File metadata and controls

29 lines (20 loc) · 864 Bytes

Queuing some promises

It is sometimes necessary to synchronize parts of asynchronous processes in order to guarantee coherency (for instance database coherency when the database engine does not support transactions). Promise lines can help in these particular cases.

Usage

Get the package:

npm install --save promise-line

Get a Promise line:

const promiseLine = require('promise-line')
const line = promiseLine()

Then push some promise factories:

line.push(() => new Promise((resolve, reject) => { /* promise 1 resolution */ }))
line.push(() => new Promise((resolve, reject) => { /* promise 2 resolution */ }))
line.push(() => new Promise((resolve, reject) => { /* promise 3 resolution */ }))

The line can be used in different unrelated parts of your code in order to avoid mangling critical sections.