0.0.6 • Published 9 years ago

promise-lock v0.0.6

Weekly downloads
5
License
WTFPL
Repository
github
Last release
9 years ago

promise-lock

NPM Version Build Status

Installation

npm install promise-lock

Usage

  1. Rejecting concurrent promises
    const lock = new PromiseLock();

    lock.on($.get('/foo'))
        .then((res)=>console.log(res))       //<-- will log the result
        .catch((res)=>console.log('Error'));

    lock.on($.get('/bar'))
        .then((res)=>console.log(res))
        .catch((res)=>console.log('Error'));//<-- will log "Error", because the lock is previously set on anothe promise
  1. Cancelling previously started promise
    const lock = new PromiseLock();

    lock.on($.get('/foo'))
        .then((res)=>console.log(res))       //<-- will never run
        .catch((res)=>console.log('Error')); //<-- will never run
    
    lock.cancel();

    lock.on($.get('/bar'))
        .then((res)=>console.log(res))       //<-- will log the result
        .catch((res)=>console.log('Error'));
0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago