-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathstore.js
More file actions
29 lines (22 loc) · 793 Bytes
/
store.js
File metadata and controls
29 lines (22 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { createStore, applyMiddleware, compose } from 'redux'
import thunk from 'redux-thunk'
import PouchDB from 'pouchdb'
import { persistentStore } from 'redux-pouchdb'
import createSagaMiddleware from 'redux-saga'
import rootReducer from './reducer'
import sagas from './sagas'
// Creates the redux store for application state
// (both the persistent storage and the canvas state)
export default function makeStore() {
const db = new PouchDB('reduxstore')
const sagaMiddleware = createSagaMiddleware()
const enhancer = compose(
persistentStore(db),
applyMiddleware(sagaMiddleware, thunk),
)
const store = createStore(rootReducer, undefined, enhancer)
for (let saga in sagas) {
sagaMiddleware.run(sagas[saga])
}
return store
}