@connected-home/redux-persist-fs-storage
Redux-Persist storage engine for React Native file system
Last updated 2 months ago by sandfox .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @connected-home/redux-persist-fs-storage 
SYNC missed versions from official npm registry.

Redux Persist FS Storage

Redux Persist storage engine for React Native file system

Inspired by redux-persist-filesystem-storage, this module works as adapter between react-native-fs and redux-persist.

Install

yarn add react-native-fs redux-persist-fs-storage

This will install react-native-fs as dependency. So make sure to link it natively:

react-native link react-native-fs

See react-native-fs's documentation for details.

Usage

Both Redux Persist v4 and v5 are supported.

Redux Persist v5:

import { persistStore, persistReducer } from 'redux-persist';
import FSStorage from 'redux-persist-fs-storage';

const persistConfig = {
  key: 'root',
  keyPrefix: '', // the redux-persist default is `persist:` which doesn't work with some file systems
  storage: FSStorage(),
};

const persistedReducer = persistReducer(persistConfig, reducer);

const store = createStore(persistedReducer);
const persistor = persistStore(store);

Redux Persist v4:

import { persistStore } from 'redux-persist';
import FSStorage from 'redux-persist-fs-storage';

const persistor = persistStore(store, { storage: FSStorage() });

The default storage location is a folder called reduxPersist in the document directory for your app on the device. You can specify folder for persistor:

import { persistStore } from 'redux-persist';
import FSStorage, { CacheDir } from 'redux-persist-fs-storage';

const cachePersistor = persistStore(store, {
  storage: FSStorage(CacheDir, 'myApp'),
});

This will create myApp folder in cache storage for iOS and Android devices. You may create multiple persistors on different directories.

Current Tags

  • 2.1.0                                ...           latest (2 months ago)

6 Versions

  • 2.1.0                                ...           2 months ago
  • 2.0.4                                ...           4 months ago
  • 2.0.3                                ...           a year ago
  • 2.0.2                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |