Skip to content

Commit

Permalink
[RELEASE] update changelog for v4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiendavid committed Jun 16, 2021
1 parent b02c4d2 commit 5b47356
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
## [4.1.0](https://github.com/alkemics/CancelablePromise/releases/tag/v4.1.0) (2021-06-16)

- Prepare release without commit
- Cancel cancelable promise returned by a then/catch callback

Consider this example:

```js
const { CancelablePromise } = require('cancelable-promise');

const promise1 = new CancelablePromise((resolve, reject, onCancel) => {
const timer = setTimeout(() => {
console.log('resolve promise1');
resolve();
}, 1000);
const abort = () => {
clearTimeout(timer);
};
onCancel(abort);
});

const promise2 = promise1.then(() => {
const promise3 = new CancelablePromise((resolve, reject, onCancel) => {
const timer = setTimeout(() => {
console.log('resolve promise 3');
resolve();
}, 1000);
const abort = () => {
clearTimeout(timer);
};
onCancel(abort);
});
return promise3;
});

setTimeout(() => {
console.log('cancel promise 2');
promise2.cancel();
}, 1500);
```

Before this release, output was:

```
resolve promise1
cancel promise 2
resolve promise 3
```

Now if you return a cancelable promise in a then/catch callback, it will canceled too when you are canceling the parent promise. Output will be:

```
resolve promise1
cancel promise 2
```

## [4.0.0](https://github.com/alkemics/CancelablePromise/releases/tag/v4.0.0) (2021-05-27)

- Update dependencies and add esm module
Expand Down

0 comments on commit 5b47356

Please sign in to comment.