Class: fetchStrategies

QuickNav

fetchStrategies

Contains out of the box Fetch Strategies which includes Cache First and Cache If Offline fetch strategies. The Cache First strategy always fetches from the local cache first regardless of offline status and returns the cached response. In addition, when online, a fetch is also made out to the server and the serverResponseCallback (if supplied) is called with the server response. The Cache If Offline strategy will fetch from the server when online and will fetch from the cache if offline.

Methods

(static) getCacheFirstStrategy(options) → {Function}

Returns the Cache First fetch strategy
Parameters:
Name Type Argument Description
options {serverResponseCallback: function()} <optional>
Options
  • options.serverResponseCallback The callback which will be called when the server responds. The callback should return a Promise which resolves when complete.
  • options.backgroundFetch Whether to do background fetching to the server when online. 'disabled' will disable background fetching, 'enabled' will enable it. The default is 'enabled'.
Returns:
Returns the Cache First fetch strategy which conforms to the Fetch Strategy API.
Type
function

(static) getCacheIfOfflineStrategy() → {Function}

Returns the Cache If Offline Fetch Strategy
Returns:
Returns the Cache If Offline fetch strategy which conforms to the Fetch Strategy API.
Type
function