erikras / erikras/react-redux-universal-hot-example

How to cansel Promise in `_ApiClient.js`

Open
#1,268 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
12.1k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

Im Want When Route Changed, If any request is pending and Related to that component is destroying cansel it...
example of cansel a promise :

```
//this promise has a way to stop what it is doing
var p1 = new Promise(function(resolve, reject, ignored){
var task = setTimeout(resolve.bind(null, "the result"), 1000);
ignored(() => clearTimeout(task));
});

//ignore the result from the above promise, triggers the ignored listener
p1.ignore();
p1.then(result => "this is never called");

//this promise cannot be cancelled, but the result can be ignored
var p2 = Promise.resolve("the result");

//the callback is not called until next event loop cycle
p2.then(result => "this is never called");

//the result is ignored, the above callback is never run
p2.ignore();
```

Im want somthing like this for all components and request.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.