- From: Gray Zhang <notifications@github.com>
- Date: Thu, 26 Feb 2015 23:26:54 -0800
- To: slightlyoff/ServiceWorker <ServiceWorker@noreply.github.com>
Received on Friday, 27 February 2015 07:27:20 UTC
I have a question: 
```js
var p = waitForUserConfirm('press OK to continue').then(() => fetch(url));
```
Since a generic `Promise#then` would "cast" a `FetchPromise` to a generic `Promise`,  `p` will not have the `abort` method, in this case how can I abort the fetch?
For this, I like the `CancellationToken` approach more since it gives control wherever a `fetch` sits in an async operation chain
```js
var token = new CancellationToken();
var p = waitForUserConfirm('press OK to continue').then(() => fetch(url, token));
app.on('navigate', token.requestCancel); // possible to cancel fetch when navigate to another page
```
---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/625#issuecomment-76350167
Received on Friday, 27 February 2015 07:27:20 UTC