1 | # @uppy/store-redux
|
2 |
|
3 | <img src="https://uppy.io/images/logos/uppy-dog-head-arrow.svg" width="120" alt="Uppy logo: a superman puppy in a pink suit" align="right">
|
4 |
|
5 | <a href="https://www.npmjs.com/package/@uppy/store-redux"><img src="https://img.shields.io/npm/v/@uppy/store-redux.svg?style=flat-square"></a>
|
6 | <a href="https://travis-ci.org/transloadit/uppy"><img src="https://img.shields.io/travis/transloadit/uppy/master.svg?style=flat-square" alt="Build Status"></a>
|
7 |
|
8 | The `ReduxStore` stores Uppy state on a key in an existing Redux store.
|
9 | The `ReduxStore` dispatches `uppy/STATE_UPDATE` actions to update state.
|
10 | When the state in Redux changes, it notifies Uppy.
|
11 | This way, you get most of the benefits of Redux, including support for the Redux Devtools and time traveling!
|
12 |
|
13 | Uppy is being developed by the folks at [Transloadit](https://transloadit.com), a versatile file encoding service.
|
14 |
|
15 | ## Example
|
16 |
|
17 | ```js
|
18 | const { combineReducers, createStore } = require('redux')
|
19 | const Uppy = require('@uppy/core')
|
20 | const ReduxStore = require('@uppy/store-redux')
|
21 | const reducers = require('./reducers')
|
22 |
|
23 | const reducer = combineReducers({
|
24 | ...reducers,
|
25 | uppy: ReduxStore.reducer
|
26 | })
|
27 |
|
28 | const store = createStore(reducer)
|
29 |
|
30 | const uppy = Uppy({
|
31 | store: ReduxStore({
|
32 | store: store
|
33 | })
|
34 | })
|
35 | ```
|
36 |
|
37 | ## Installation
|
38 |
|
39 | ```bash
|
40 | $ npm install @uppy/store-redux --save
|
41 | ```
|
42 |
|
43 | We recommend installing from npm and then using a module bundler such as [Webpack](http://webpack.github.io/), [Browserify](http://browserify.org/) or [Rollup.js](http://rollupjs.org/).
|
44 |
|
45 | Alternatively, you can also use this plugin in a pre-built bundle from Transloadit's CDN: Edgly. In that case `Uppy` will attach itself to the global `window.Uppy` object. See the [main Uppy documentation](https://uppy.io/docs/#Installation) for instructions.
|
46 |
|
47 | ## Documentation
|
48 |
|
49 | Documentation for this plugin can be found on the [Uppy website](https://uppy.io/docs/stores#ReduxStore).
|
50 |
|
51 | ## License
|
52 |
|
53 | [The MIT License](./LICENSE).
|