📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

rxjs-retry-delay

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rxjs-retry-delay

RxJS retry operator with delay and max attempts strategy

0.0.1
Source
npm
Version published
Weekly downloads
136
-16.56%
Maintainers
1
Weekly downloads
 
Created
Source

RxJS-retry-delay operator for rxjs@^6.0.0

RxJS retry pipeable operator that supports delay and max attempts strategy

Prerequisites

rxjs: ^6.0.0

Installation and Usage

npm install rxjs-retry-delay

Basic usage with default values:

import { ajax } from 'rxjs/ajax';
import { retryWithDelay } from 'rxjs-retry-delay';

function getUserById(id) {
  return ajax.getJSON(`https://jsonplaceholder.typicode.com/users/${id}`)
    .pipe(retryWithDelay());
}

Example above will retry 3 times with interval of 1s

function getUserById(id) {
  return ajax.getJSON(`https://jsonplaceholder.typicode.com/users/${id}`).pipe(
    retryWithDelay({
      delay: 1000,
      maxRetryAttempts: 5,
      scalingFactor: 2
    })
  );
}

Example above will retry after 1s, 2s, 4s, 8s, 16s

In excludedStatusCodes we can pass response statuses after which we don't want to retry

function getUserById(id) {
  return ajax.getJSON(`https://jsonplaceholder.typicode.com/users/${id}`).pipe(
    retryWithDelay({
      delay: 1000,
      maxRetryAttempts: 10,
      scalingFactor: 2,
      excludedStatusCodes: [500]
    })
  );
}

In example above, when response status is 500 it will throw error immediately.

Authors

  • Chris Filipowski - filipows

License

This project is licensed under the MIT License - see the LICENSE file for details

Keywords

rxjs

FAQs

Package last updated on 04 Sep 2018

Did you know?

Socket

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