$resource timeouts

144 views
Skip to first unread message

Jonathan Price

unread,
Mar 30, 2015, 3:46:18 PM3/30/15
to ang...@googlegroups.com
We're building an ionic mobile application, and I need to handle resource requests that never return.  I was hoping to has some sort of universal timeout for all of my resources (say, bail out if the server doesn't respond within 10 seconds), but I'm not really sure how to proceed.  Any of you doing something like this?

Tandon, Rishi

unread,
Mar 30, 2015, 4:04:41 PM3/30/15
to ang...@googlegroups.com
You can try using $httpProvider.interceptors.
On Mon, Mar 30, 2015 at 3:46 PM, Jonathan Price <purit...@gmail.com> wrote:
We're building an ionic mobile application, and I need to handle resource requests that never return.  I was hoping to has some sort of universal timeout for all of my resources (say, bail out if the server doesn't respond within 10 seconds), but I'm not really sure how to proceed.  Any of you doing something like this?

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.



--
Rishi Tandon
Pearson Learning Technology Group

Mobile: (310) 926-9032

Pearson
Always Learning
Learn more at www.pearson.com

Puritan Paul

unread,
Mar 30, 2015, 4:11:21 PM3/30/15
to ang...@googlegroups.com
Wouldn’t that require an actual response from the server?  I’m more concerned with a timeout, i.e. lack of server response.


You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/gOfINt2TsW8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.

Michael Bielski

unread,
Mar 30, 2015, 4:16:03 PM3/30/15
to ang...@googlegroups.com
There is a Timeout option in the $http specs. You pass it in your config.

  • timeout – {number|Promise} – timeout in milliseconds, or promise that should abort the request when resolved.

Puritan Paul

unread,
Mar 30, 2015, 4:26:34 PM3/30/15
to ang...@googlegroups.com
Right, there’s the same parameter for $resouce, which is probably what I’ll do.  Which means I’ll need to declare it on a per-resource basis, right?  Was just wondering if there was something more global.


On Mar 30, 2015, at 1:16 PM, 'Michael Bielski' via AngularJS <ang...@googlegroups.com> wrote:

There is a Timeout option in the $http specs. You pass it in your config.

  • timeout – {number|Promise} – timeout in milliseconds, or promise that should abort the request when resolved.

Michael Bielski

unread,
Mar 30, 2015, 4:37:40 PM3/30/15
to ang...@googlegroups.com
Your $resource usage should be in a factory/service, so you can declare it globally within that service, or you can put it into another service that houses your utility functions/variables and inject that into your other services.

Puritan Paul

unread,
Mar 30, 2015, 5:13:48 PM3/30/15
to ang...@googlegroups.com
Ah.  I tend to use resources directly within my controllers, but what you’re saying makes sense.


On Mar 30, 2015, at 1:37 PM, 'Michael Bielski' via AngularJS <ang...@googlegroups.com> wrote:

Your $resource usage should be in a factory/service, so you can declare it globally within that service, or you can put it into another service that houses your utility functions/variables and inject that into your other services.

Reply all
Reply to author
Forward
0 new messages