Skip to content

Latest commit

 

History

History
43 lines (32 loc) · 1.39 KB

README.md

File metadata and controls

43 lines (32 loc) · 1.39 KB

next-make-cancelable

Make promise cancelable for next.

version license size download

installation

npm install -S @jswork/next-make-cancelable

usage

import '@jswork/next-make-cancelable';

const somePromise = new Promise(r => setTimeout(r, 1000));
const cancelable = nx.makeCancelable(somePromise);

cancelable
  .promise
  .then(() => console.log('resolved'))
  .catch(({isCanceled, ...error}) => console.log('isCanceled', isCanceled));

// Cancel promise
cancelable.cancel();

license

Code released under the MIT license.