grossbart / refreshable-remote-data-ts

Refresh strategies for the RemoteData type

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Refreshable RemoteData

Description

When fetching data asynchronously, is is useful to keep track of the progress to communicate the current state of the system. The RemoteData type can be used to express this in a concise way.

Refreshable RemoteData extends this concept. When we need to refresh the network resource, we can avoid falling back to a loading state: If we have data available from a previous fetch, we can keep it around while we load new data in the background.

The following refresh strategies are available:

  1. Stale-while-revalidate: Keep returning data that was already fetched until new data is available.
  2. Stale-if-error: Same as above, but if the next value is an error, discard it and return existing stale data instead (if we already have it).

This library builds on:

Installation

npm install --save fp-ts @devexperts/remote-data-ts
npm install --save refresh-remote-data-ts

About

Refresh strategies for the RemoteData type

License:Mozilla Public License 2.0


Languages

Language:TypeScript 97.3%Language:JavaScript 2.7%