可取消的 Promise
https://medium.com/@benlesh/promise-cancellation-is-dead-long-live-promise-cancellation-c6601f1f5082
proposal-cancelable-promises 被撤销了
- 可以使用 Bluebird 的 Promise ```javascript var result = makeCancellableRequest(…);
var firstConsumer = result.then(…); var secondConsumer = result.then(…);
考虑 promise 有多个消费者等情况<br />详见文档 [http://bluebirdjs.com/docs/api/cancellation.html](http://bluebirdjs.com/docs/api/cancellation.html)
Promise.race( ) 被丢弃的那个 promise 还是会执行完
```javascript
let p1 = new Promise(r => {
setTimeout(() => {
console.log('p1 start');
r('p1')
}, 2000);
})
let p2 = new Promise(r => {
setTimeout(() => {
console.log('p2 start');
r('p2')
}, 200);
})
Promise.race([p1, p2]).then(who => console.log(who + ' done'))
// p2 start
// p2 done
// p1 start
取消请求
https://github.com/axios/axios#cancellation