How to implement angular.js repetition with exponential indent?

How do I implement repeat logic in angular.js with exponential back off?

  • Would there be a good place for the logic in $ httpProvider.requestInterceptors?
  • Can I selectively select it with some $ http services and not others?
+3


source to share


2 answers


This is an old post, but here are my thoughts. I would use responseInterceptor

. Since you can simply return another promise, you can decide how to try again. You have access to $ http config

in the interceptor, so you can add custom configuration to determine what should be indented (or whether to apply retry logic at all).



+2


source


For upcoming people: using some pre-available components and module looks more Angular. So you can try one of these backo2 or angular-backoff



Every link is used here. However, don't use setTimeout the wrong way Angular and you should use $ interval or $ timeout.

+1


source







All Articles