Redux persist adapter for electron-store
Branch: master
Clone or download
Philipp Sperber
Latest commit 85f31ed Jan 28, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib - Refactoring Nov 2, 2018
test - Refactoring Nov 2, 2018
types Added typings for typescript (resolves #8) Jan 25, 2019
.gitignore Update .gitignore Nov 8, 2017
.travis.yml Update .travis.yml Nov 6, 2018
README.md Added Travis Badge Nov 6, 2018
package-lock.json Bumped version after merge PR Jan 28, 2019
package.json Bumped version after merge PR Jan 28, 2019

README.md

redux-persist-electron-storage

npm version npm downloads Build Status Greenkeeper badge

Storage adapter to use electron-store with redux-persist

Installation

npm

npm i -S electron-store redux-persist-electron-storage

yarn

yarn add electron-store redux-persist-electron-storage

Usage

To use redux-persist-electron-storage, configure redux-persist according to its documentation.

Modify the classic redux-persist configuration as follows:

  • Do not import redux-persist/lib/storage anymore, as we use an alternative storage.
  • Import redux-persist-electron-storage:
import createElectronStorage from "redux-persist-electron-storage";
  • Modify the options for persistReducer in order to use the storage dedicated to Electron:
const persistConfig = {
  key: 'root',
  storage: createElectronStorage()
}

const persistedReducer = persistReducer(persistConfig, rootReducer)

You can either pass an instance of electron-store or pass options like below:

const electronStore = new ElectronStore()
createElectronStorage({
  electronStore
})
createElectronStorage({
  electronStoreOpts: {
    encryptionKey: 'MY_ENCRYPTION_KEY'
  }
})

Hint: The passed instance is preferred over passed options