1.0.5 • Published 7 years ago

redux-simplestorage v1.0.5

Weekly downloads
8
License
ISC
Repository
github
Last release
7 years ago

redux-simplestorage

Dependency Status js-standard-style Commitizen friendly

Use this to seamlessly store data in localStorage via redux actions.

Installation

npm i redux-simplestorage

import { createStore, applyMiddleware } from 'redux'
import storageMiddleware from 'redux-simplestorage'
const reduxStore = applyMiddleware([storageMiddleware])(createStore)

Usage

To store data in localStorage via redux action, simply include a storage key. The storage value is an object whose keys will be stored in localStorage.

const STORE_SESSION = 'STORE_SESSION'
const SESSION = 'SESSION'

export function storeSession(session) {
    return {
        type: STORE_SESSION,
        storage: {
            [SESSION]: session
        }
    }
}

Later on...

const session = localStorage.getItem(SESSION)

Demo

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago