Skip to content

3.0.0

Compare
Choose a tag to compare
@sebdvd sebdvd released this 19 Apr 13:43
· 1452 commits to master since this release
1987549
  • Complete rewrite of CancelablePromise.
    Now promises returned from Promise API such as then or catch can cancel the root promise and all promises created from this root promise:
// CancelablePromise v2
import CancelablePromise from 'cancelable-promise';

const promise = new CancelablePromise((resolve) => setTimeout(resolve, 1))
  .then(() => console.log('callback2 executed'))
  .then(() => console.log('callback3 executed'));
promise.cancel();
// logs:
// callback2 executed
// callback3 executed
// CancelablePromise v3
import CancelablePromise from 'cancelable-promise';

const promise = new CancelablePromise((resolve) => setTimeout(resolve, 1))
  .then(() => console.log('callback2 executed'))
  .then(() => console.log('callback3 executed'));
promise.cancel();
// no logs
  • a functionnal util has been added:
import { cancelable } from 'cancelable-promise';

cancelable(new Promise((resolve) => setTimeout(resolve, 1)));
  • UMD module, CancelablePromise can be loaded in browser