exclusive-promise
Use this when you have a function that returns a promise and you want that promise to be canceled if the function is called again.
* Native promises don't support cancellation, so you must use bluebird Promise
install
npm install exclusive-promise bluebird
example
const Promise = const exclusivePromise = const fn = { return { }}const exclusiveFn = const a = // promise chain "a" beginsconst b = // promise chain "a" is canceled, "b" begins
API
exclusivePromise(fn)
fn: function
a function that creates and returns a promise- returns:
function
a function that callsfn
after canceling the promise from the previous call. Arguments are passed through tofn
.