Skip to content

Commit

Permalink
feat(docs) Add FAQ about cancelling request
Browse files Browse the repository at this point in the history
Closes #926, closes #1145, closes #1377, closes #1391
  • Loading branch information
bostrom committed Dec 30, 2016
1 parent 6883075 commit 8552c51
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ The project lacks resources to answer questions regarding general usage and prob
* Please **enclose your code in [fenced blocks](https://help.github.com/articles/creating-and-highlighting-code-blocks/)** for readability.

The maintainers may opt to close issues that don't follow these guidelines.

**Also remember:**

* Pull requests fixing problems are highly appreciated ;)

19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Watch [a video introduction of a talk I gave at Devoxx France](http://www.parley
- [How can I access the unrestangularized element as well as the restangularized one?](#how-can-i-access-the-unrestangularized-element-as-well-as-the-restangularized-one)
- [Restangular fails with status code 0](#restangular-fails-with-status-code-0)
- [Why does this depend on Lodash / Underscore?](#why-does-this-depend-on-lodash--underscore)
- [How do I cancel a request?](#how-do-i-cancel-a-request)
- [Supported Angular versions](#supported-angular-versions)
- [Server Frameworks](#server-frameworks)
- [Releases Notes](#releases-notes)
Expand Down Expand Up @@ -1306,6 +1307,24 @@ So, why not use it? If you've never heard of them, by using Restangular, you cou

**[Back to top](#table-of-contents)**

#### How do I cancel a request?

Sometimes you may wish to cancel a request, this is how you would do it:

```
var canceler = $q.defer();
Restangular.all('users').withHttpConfig({timeout: canceler.promise}).get();
canceler.resolve(); // cancels the request
```

This is a little counterintuitive, so let me explain. Restangular is built on top of `$http`, which takes a timeout parameter. As per the $http docs:

timeout in milliseconds, or promise that should abort the request when resolved.

Resolving the promise (canceler in this case), will cancel the request.

**[Back to top](#table-of-contents)**

# Supported Angular versions

Restangular supports all Angular versions from 1.0.X - 1.5.X
Expand Down

0 comments on commit 8552c51

Please sign in to comment.