redux-effects-fetchr
Caching middleware for redux-effects-fetchr.
Installation
npm install --save redux-effects-fetchr-cache
Usage
Installing the middleware:
;;;;;; const fetchr = xhrPaht: '/api'; const cacheConfig = max: 500 maxAge: 1000 * 60 * 60; const store = ;
redux-effects-fetchr-cache must be installed before redux-effects-fetchr.
API
Middleware
fetchrCacheMiddleware(cacheConfig, [options])
Creates redux middleware.
Arguments
cacheConfig
(Object): See lru-cahce API docs for more info.options
(Object):excludes
(Array): An array of the resource names to not use the cache. Defaults[]
.fromCache
(Function): Checks whether an action is target to obtain from cache. Defaults() => true
.- Arguments:
action
(Object): An action.state
(Object): The current state of the Store.
- Returns:
- (Boolean): If
true
, uses cache to obtain the resource.
- (Boolean): If
- Arguments:
toCache
(Function): Checks whether an action is target to store to cache. Defaults() => true
.- Arguments:
action
(Object): An action.state
(Object): The current state of the Store.
- Returns:
- (Boolean): If
true
, saves the obtaining resource to cache.
- (Boolean): If
- Arguments:
resetCache
(Function): reset cache if resetCache function returns true. Defaults() => false
.- Arguments:
action
(Object): An action.state
(Object): The current state of the Store.
- Returns:
- (Boolean): If
true
, reset all cache.
- (Boolean): If
- Arguments:
Returns
- (Function): Redux middleware.