Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@specter/redux-effects-specter-cache

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@specter/redux-effects-specter-cache

cache structure for redux middleware of specter

  • 0.5.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

redux-effects-specter-cache

Caching middleware for @specter/redux-effects-specter.

Installation

npm install --save @specter/specter  \                  # peer dependency
                   @specter/storage \                   # peer dependency
                   @specter/redux-effects-specter \     # peer dependency
                   @specter/redux-effects-specter-cache

Usage

Installing the middleware:

import { createStore, applyMiddleware } from 'redux';
import { Client } from '@specter/specter';
import stepsMiddleware from 'redux-effects-steps';
import specterMiddleware from '@specter/redux-effects-specter';
import specterCacheMiddleware from '@specter/redux-effects-specter-cache';
import rootReducer from './reducers';

const client = new Client({
  base: '/xhr'
});

const cacheConfig = {
  max: 500,
  maxAge: 1000 * 60 * 60
};

const cacheMiddlewareConfig = {
  excludes: [
    "greet" // expected service name of specter
  ]
}

const store = createStore(
  rootReducer,
  applyMiddleware(
    stepsMiddleware,
    specterCacheMiddleware({ cacheConfig, cacheMiddlewareConfig }),
    specterMiddleware(client)
  )
);

redux-effects-specter-cache must be applied before redux-effects-specter.

API

Middleware

specterCacheMiddleware(cacheConfig, [options])

Creates redux middleware.

Arguments
  • options (Object) : LRE-cache option and middleware option
    • cacheConfig (Object): See lru-cahce API docs for more info.
    • middlewareOption (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.
      • 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.
      • 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.
Returns
  • (Function): Redux middleware.

Keywords

FAQs

Package last updated on 10 Jul 2020

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc