Skip to content

Commit

Permalink
(api): proxy modules, some cleanup (#703)
Browse files Browse the repository at this point in the history
* (api): proxy modules, some cleanup

* Update README.md
  • Loading branch information
rt2zz committed Feb 4, 2018
1 parent a40e4a5 commit 0614ee5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 53 deletions.
35 changes: 11 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ Persist and rehydrate a redux store.

[![build status](https://img.shields.io/travis/rt2zz/redux-persist/master.svg?style=flat-square)](https://travis-ci.org/rt2zz/redux-persist) [![npm version](https://img.shields.io/npm/v/redux-persist.svg?style=flat-square)](https://www.npmjs.com/package/redux-persist) [![npm downloads](https://img.shields.io/npm/dm/redux-persist.svg?style=flat-square)](https://www.npmjs.com/package/redux-persist)

Redux Persist takes your redux state object and saves it to persisted storage. On app launch, it retrieves this persisted state and saves it back to redux.

**Note:** These instructions are for redux-persist v5. For a list of breaking changes between v4 and v5, see our [migration guide](./docs/MigrationGuide-v5.md).
[v4](https://github.com/rt2zz/redux-persist/tree/v4) will be supported for the forseeable future, and if it works well for your use case you are encouraged to stay on v4.

## Quickstart
`npm install redux-persist`

Expand All @@ -26,13 +21,13 @@ Basic usage involves adding `persistReducer` and `persistStore` to your setup. *

import { createStore } from 'redux'
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'
import storage from 'redux-persist/lib/storage' // defaults to localStorage for web and AsyncStorage for react-native

import rootReducer from './reducers'

const persistConfig = {
key: 'root',
storage: storage,
storage,
}

const persistedReducer = persistReducer(persistConfig, rootReducer)
Expand All @@ -47,15 +42,9 @@ export default () => {
If you are using react, wrap your root component with [PersistGate](./docs/PersistGate.md). This delays the rendering of your app's UI until your persisted state has been retrieved and saved to redux. **NOTE** the `PersistGate` loading prop can be null, or any react instance, e.g. `loading={<Loading />}`

```js
import React from 'react'
import { Provider } from 'react-redux'
import { PersistGate } from 'redux-persist/lib/integration/react'

import configureStore from './store/configureStore'
let { store, persistor } = configureStore()
import { PersistGate } from 'redux-persist/integration/react'

// import your necessary custom components.
import { RootComponent } from './components'
// ... normal setup, create store and persistor, import components etc.

const App = () => {
return (
Expand All @@ -66,8 +55,6 @@ const App = () => {
</Provider>
);
};

export default App
```

## API
Expand All @@ -91,13 +78,13 @@ export default App

#### `persistor object`
- the persistor object is returned by persistStore with the following methods:
- `.purge(keys)`
- `.purge()`
- purges state from disk and returns a promise
- `flush()`
- `.flush()`
- immediately writes all pending state to disk and returns a promise
- `pause()`
- `.pause()`
- pauses persistence
- `persist()`
- `.persist()`
- resumes persistence

## State Reconciler
Expand All @@ -113,7 +100,7 @@ This will auto merge one level deep. Auto merge means if the some piece of subst
- **INCOMING STATE**: `{ foo: incomingFoo }`
- **INITIAL STATE**: `{ foo: initialFoo, bar: initialBar }`
- **RECONCILED STATE**: `{ foo: incomingFoo, bar: initialBar }`
3. autoMergeLevel2
3. autoMergeLevel2 (`import autoMergeLevel2 from 'redux-persist/lib/stateReconciler/autoMergeLevel2'`)
This acts just like autoMergeLevel1, except it shallow merges two levels
- **INCOMING STATE**: `{ foo: incomingFoo }`
- **INITIAL STATE**: `{ foo: initialFoo, bar: initialBar }`
Expand Down Expand Up @@ -222,8 +209,8 @@ The createTransform function takes three parameters.

## Storage Engines
- **localStorage** `import storage from 'redux-persist/lib/storage'`
- **sessionStorage** `import sessionStorage from 'redux-persist/lib/storage/session'`
- **AsyncStorage** react-native `import storage from 'redux-persist/lib/storage'`
- **sessionStorage** `import storageSession from 'redux-persist/lib/storage/session'`
- **AsyncStorage** react-native `import { AsyncStorage } from 'react-native'`
- **[localForage](https://github.com/mozilla/localForage)** recommended for web
- **[electron storage](https://github.com/psperber/redux-persist-electron-storage)** Electron support via [electron store](https://github.com/sindresorhus/electron-store)
- **[redux-persist-filesystem-storage](https://github.com/robwalkerco/redux-persist-filesystem-storage)** react-native, to mitigate storage size limitations in android ([#199](https://github.com/rt2zz/redux-persist/issues/199), [#284](https://github.com/rt2zz/redux-persist/issues/284))
Expand Down
4 changes: 4 additions & 0 deletions integration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Proxy package to enable
```js
import { PersistGate } from 'redux-persist/integration/react'
```
7 changes: 7 additions & 0 deletions integration/react/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "redux-persist/integration/react",
"private": true,
"main": "../../lib/integration/react",
"module": "../../es/integration/react",
"jsnext:main": "../../es/integration/react"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"lint-staged": {
"src/**/*.js": [
"prettier --no-semi --single-quote --trailing-comma --parser=flow --write",
"prettier --write",
"git add"
]
},
Expand Down
28 changes: 0 additions & 28 deletions src/utils/curry.js

This file was deleted.

0 comments on commit 0614ee5

Please sign in to comment.