Bradley Meck (2015-02-03T20:12:37.000Z)
Made a run through of using purely promises to achieve this result and it
ends up with nesting and an extra try/catch which is less than stellar:

```
let fetchish = function () {
  return new Promise((f,r) => {
    // technically we need a try catch around all the functions in here to
act like an async function, but lets skip some for brevity
    let client = new Client();
    client.on('error', r);

    client.get().then((v) => {
      let body;
      try {
        body = JSON.parse(v);
      }
      catch (e) { r(e); return; }
      f(body);
    }, (e) => r(e));
  });
}
```

We can track when client is in an error and keep a list of pending promises
to reject, though not all promise consumers will want to reject when any
error occurs, so the pure Promises solution is going to win in that case.

And the cancellation token is just like a deferred? Where you pass a
rejection function around outside of the promise initializer?

On Tue, Feb 3, 2015 at 2:02 PM, Benjamin (Inglor) Gruenbaum <
inglor at gmail.com> wrote:

> Thanks, in case anyone is wondering this is the relevant result:
> https://esdiscuss.org/topic/future-cancellation
>
> On Tue, Feb 3, 2015 at 9:50 PM, Brendan Eich <brendan at mozilla.org> wrote:
>
>> Benjamin (Inglor) Gruenbaum wrote:
>>
>>> Cancellation of promises is something that has been debated several
>>> times (not sure if at all in esdiscuss).
>>>
>>
>> Many times:
>>
>> https://www.google.com/search?q=site%3Aesdiscuss.org%20cancel%20promise
>>
>> Google site: search is your friend.
>>
>> /be
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150203/44bd7655/attachment.html>
d at domenic.me (2015-02-17T17:58:20.848Z)
Made a run through of using purely promises to achieve this result and it
ends up with nesting and an extra try/catch which is less than stellar:

```
let fetchish = function () {
  return new Promise((f,r) => {
    // technically we need a try catch around all the functions in here to act like an async function, but lets skip some for brevity
    let client = new Client();
    client.on('error', r);

    client.get().then((v) => {
      let body;
      try {
        body = JSON.parse(v);
      }
      catch (e) { r(e); return; }
      f(body);
    }, (e) => r(e));
  });
}
```

We can track when client is in an error and keep a list of pending promises
to reject, though not all promise consumers will want to reject when any
error occurs, so the pure Promises solution is going to win in that case.

And the cancellation token is just like a deferred? Where you pass a
rejection function around outside of the promise initializer?