Re: [ServiceWorker] Returning a FetchPromise from fetch() (#625)

@tabatkins 
> in real usage, rejecting just means that everybody puts a check at the top of their reject handler that does nothing if it was a cancel-rejection.

Yes, I know that and 100% with you. For example, jQuery has same approach for their abort action and it's really annoying. But I am not sure if forever-pending is better approach. Ability to know if promise/request is canceled (from other part of code) is a really usable thing.
Cancelable Promises seems absolutely better for this, altough I do not know their current state. 
I can imagine Cancelable Promises as this:

```javascript
var req = new Promise(function(fullfill, reject, cancel) {
  // ...
});

req
  .then(function onFullfill() {}, function onReject() {}, function onCancel() {})
  .catch(function onReject() {})
  .cancelled(function onCancel() {});
```

This version is backwards-compatible, it has no problems with casting and for old-Promises (current, non-cancelable) cancelation will be just forever-pending state (+this version is polyfillable).

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/625#issuecomment-76635193

Received on Sunday, 1 March 2015 22:29:49 UTC