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 | [![npm version](https://img.shields.io/npm/v/@uppy/store-redux.svg?style=flat-square)](https://www.npmjs.com/package/@uppy/store-redux)
|
6 | ![CI status for Uppy tests](https://github.com/transloadit/uppy/workflows/Tests/badge.svg)
|
7 | ![CI status for Companion tests](https://github.com/transloadit/uppy/workflows/Companion/badge.svg)
|
8 | ![CI status for browser tests](https://github.com/transloadit/uppy/workflows/End-to-end%20tests/badge.svg)
|
9 |
|
10 | The `ReduxStore` stores Uppy state on a key in an existing Redux store.
|
11 | The `ReduxStore` dispatches `uppy/STATE_UPDATE` actions to update state.
|
12 | When the state in Redux changes, it notifies Uppy.
|
13 | This way, you get most of the benefits of Redux, including support for the Redux Devtools and time traveling!
|
14 |
|
15 | Uppy is being developed by the folks at [Transloadit](https://transloadit.com), a versatile file encoding service.
|
16 |
|
17 | ## Example
|
18 |
|
19 | ```js
|
20 | import Uppy from '@uppy/core'
|
21 | import * as ReduxStore from '@uppy/store-redux'
|
22 | import * as Redux from 'redux'
|
23 |
|
24 | function createStore (reducers = {}) {
|
25 | const reducer = Redux.combineReducers({ ...reducers, uppy: ReduxStore.reducer })
|
26 | return Redux.createStore(reducer)
|
27 | }
|
28 |
|
29 | const store = new ReduxStore.ReduxStore({ store: createStore() })
|
30 | const uppy = new Uppy({ store })
|
31 | ```
|
32 |
|
33 | ## Installation
|
34 |
|
35 | ```bash
|
36 | $ npm install @uppy/store-redux
|
37 | ```
|
38 |
|
39 | 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.
|
40 |
|
41 | ## Documentation
|
42 |
|
43 | Documentation for this plugin can be found on the [Uppy website](https://uppy.io/docs/stores#ReduxStore).
|
44 |
|
45 | ## License
|
46 |
|
47 | [The MIT License](./LICENSE).
|