New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

redux-storage

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-storage

Persistence layer for redux with flexible backends

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.4K
increased by17.5%
Maintainers
1
Weekly downloads
 
Created
Source

redux-storage

Installation

npm install --save redux-storage

Usage

import storage from 'redux-storage'
import createEngine from 'redux-storage/engines/reactNativeAsyncStorage';

const storageMiddleware = storage.middleware(createEngine('redux'));

import { createStore, applyMiddleware } from 'redux';
const store = applyMiddleware(storageMiddleware)(createStore)(reducer);

Details

Engines

redux-storage/engines/reactNativeAsyncStorage

This will use AsyncStorage out of react-native.

redux-storage/engiens/localStorage

Stores everything inside window.localStorage. Warning! localStorage does not expose a async API and every save/load operation will block the JS thread!

Actions

import { LOAD, SAVE } from 'redux-storage';

function storeAwareReducer(state = { loaded: false }, action) {
    switch (action.type) {
        case LOAD:
            return { ...state, laoded: true };

        case SAVE:
            console.log('Something has changed and written to disk!');

        default:
            return state;
    }
}

Decorators

Filter

Use this decorator to write only part of your state tree to disk.


import storage from 'redux-storage'

storageMiddleware = storage.decorators.filter([
    ['some', 'key'],
    ['another', 'very', 'nested', 'key']
])(storageMiddleware);
Debounce

This decorator will delay the expensive save operation for the given ms. Every new change to the state tree will reset the timeout!

import storage from 'redux-storage'

storageMiddleware = storage.decorators.debounce(1500)(storageMiddleware);

Todo

  • Write tests for everything!

Keywords

FAQs

Package last updated on 28 Jul 2015

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