cvut/fittable

View on GitHub
src/store/persistence.js

Summary

Maintainability
A
0 mins
Test Coverage
import { compose } from 'redux'
import persistState from 'redux-localstorage'
import adapter from 'redux-localstorage/lib/adapters/localStorage'
import filter from 'redux-localstorage-filter'

// Key under which state will be stored
const STORAGE_KEY = 'fittable'
// What parts of store should be persisted
const STORAGE_FILTER = 'settings'

const storage = compose(
  filter(STORAGE_FILTER)
)(adapter(window.localStorage))

const createPersistentStore = () => {
  return persistState(storage, STORAGE_KEY)
}

export default createPersistentStore