From: Tab Atkins Jr. [[email protected]]

> I think you're making this far too complicated.  It's much simpler than this:

I disagree. An abstraction boundary gets broken. Consider:

```js
function getUser1() {
  return doXHR("/user.json");
}

function getUser2() {
  return { "name": "domenic" };
}

function getUser3() {
  return doXHR("/user.json").then(function (user) {
    user.metadata = "<meta> tags are old school";
  });
}
```

Here, `getUser1()` returns a cancellable promise, but `getUser2()` does not, 
even though they should have the same semantics. Worse, `getUser3()` isn't 
cancellable, even though it was originally derived from an XHR. Trying to fix 
the `getUser3()` case is what takes you down the slope of complex additional 
semantics.

Much better would be if a hypothetical future XHR utility returned a `{ 
promise, abort }` object, with no logical connection between the `abort` and 
the `promise` (besides maybe rejecting the promise with a well-known error). 
This seems much better than trying to make a general cancellation concept for 
promises and overloading them with additional semantics about the operation 
being performed.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to