Skip to content

Commit

Permalink
Update readme with all config options and defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
robwalkerco committed Oct 14, 2020
1 parent a5314b6 commit f21e0e6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ yarn add redux-persist-filesystem-storage@1
```

Then, as [rn-fetch-blob](https://github.com/joltup/rn-fetch-blob) is a dependency of this project, we need to ensure its linked with

```
react-native link rn-fetch-blob
```

(or check [their docs](https://github.com/joltup/rn-fetch-blob#user-content-installation)).

## usage

Simply use 'FilesystemStorage' as the storage option in the redux-persist config.

```javascript
import FilesystemStorage from 'redux-persist-filesystem-storage'
...
Expand All @@ -42,17 +46,24 @@ const persistConfig = {
```

## usage with custom options

```javascript
import FilesystemStorage from 'redux-persist-filesystem-storage'
...

// These are all the config options, with their default values
FilesystemStorage.config({
storagePath: `${RNFetchBlob.fs.dirs.DocumentDir}/persistStore`
storagePath: `${RNFetchBlob.fs.dirs.DocumentDir}/persistStore`,
encoding: "utf8",
toFileName: (name: string) => name.split(":").join("-"),
fromFileName: (name: string) => name.split("-").join(":"),
});

const persistConfig = {
key: 'root',
storage: FilesystemStorage,
toFileName: (name: string) => name.split(":").join("-"),
fromFileName: (name: string) => name.split("-").join(":")
}

...
Expand Down

0 comments on commit f21e0e6

Please sign in to comment.