Socket
Socket
Sign inDemoInstall

@http-ext/plugin-retry

Package Overview
Dependencies
4
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @http-ext/plugin-retry

> A retry plugin for [HttpExt](https://github.com/jscutlery/http-ext).


Version published
Weekly downloads
1
decreased by-50%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

@http-ext/plugin-retry

A retry plugin for HttpExt.

This plugin retries failed network requests using a configurable back-off strategy.

Requirements

The plugin requires @http-ext/core and @http-ext/angular to be installed.

Installation

yarn add @http-ext/plugin-retry

or

npm install @http-ext/plugin-retry

Usage

The whole configuration object is optional.

import { HttpExtModule } from '@http-ext/angular';
import { createRetryPlugin } from '@http-ext/plugin-retry';

@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    HttpClientModule,
    HttpExtModule.forRoot({
      plugins: [createRetryPlugin()]
    })
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

Available options

You can give a partial configuration object it will be merged with default values.

PropertyTypeDefault valueDescription
initialIntervalMsnumber200Duration before the first retry.
maxIntervalMsnumber60000Maximum time span before retrying.
maxRetriesnumber10Maximum number of retries.
shouldRetryRetryPredicateisServerErrorPredicate function to know which failed request should be retried.
conditionRequestCondition() => truePredicate function to know which request the plugin should handle.

Here is an example passing a configuration object.

import { MemoryStorage } from '@http-ext/plugin-cache';

@NgModule({
  imports: [
    HttpExtModule.forRoot({
      plugins: [
        createRetryPlugin({
          initialIntervalMs: 1000,
          maxIntervalMs: 120000,
          maxRetries: 15,
          shouldRetry: response => response.status !== 404,
          condition: ({ request }) => request.url.includes('api.github.com')
        })
      ]
    })
  ]
})
export class AppModule {}

FAQs

Last updated on 14 Jan 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc