File tree Expand file tree Collapse file tree 5 files changed +45
-6
lines changed Expand file tree Collapse file tree 5 files changed +45
-6
lines changed Original file line number Diff line number Diff line change 1
1
"use strict" ;
2
+ var redux_pouchdb_1 = require ( 'redux-pouchdb' ) ;
2
3
var _types_1 = require ( '../../actions/_types' ) ;
3
4
var store_1 = require ( '../../store' ) ;
4
5
var _progress = {
@@ -50,4 +51,4 @@ function progressReducer(progress, action) {
50
51
}
51
52
}
52
53
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
53
- exports . default = progressReducer ;
54
+ exports . default = redux_pouchdb_1 . persistentReducer ( progressReducer ) ;
Original file line number Diff line number Diff line change 1
1
"use strict" ;
2
+ var env = 'dev' ;
2
3
var redux_1 = require ( 'redux' ) ;
4
+ var redux_thunk_1 = require ( 'redux-thunk' ) ;
5
+ var PouchDB = require ( 'pouchdb' ) ;
6
+ var redux_pouchdb_1 = require ( 'redux-pouchdb' ) ;
3
7
var reducers_1 = require ( '../reducers' ) ;
4
- exports . store = redux_1 . createStore ( reducers_1 . default , { } ) ;
8
+ var db = new PouchDB ( 'coderoad' ) ;
9
+ var middlewares = [ redux_thunk_1 . default ] ;
10
+ if ( env && env === 'dev' ) {
11
+ var createLogger = require ( 'redux-logger' ) ;
12
+ var logger = createLogger ( ) ;
13
+ middlewares . push ( logger ) ;
14
+ }
15
+ var createStoreWithMiddleware = redux_1 . compose ( redux_1 . applyMiddleware . apply ( void 0 , middlewares ) , redux_pouchdb_1 . persistentStore ( db ) ) ( redux_1 . createStore ) ;
16
+ exports . store = createStoreWithMiddleware ( reducers_1 . default , { } ) ;
Original file line number Diff line number Diff line change 42
42
"highlights" : " 1.3.1" ,
43
43
"marked" : " 0.3.5" ,
44
44
"material-ui" : " 0.15.0-beta.2" ,
45
+ "pouchdb" : " ^5.3.2" ,
45
46
"react" : " 15.0.1" ,
46
47
"react-dom" : " 15.0.1" ,
47
48
"react-redux" : " 4.4.5" ,
48
49
"react-tap-event-plugin" : " 1.0.0" ,
49
- "redux" : " 3.5.1"
50
+ "redux" : " 3.5.2" ,
51
+ "redux-logger" : " ^2.6.1" ,
52
+ "redux-pouchdb" : " 0.0.7" ,
53
+ "redux-thunk" : " ^2.0.1"
50
54
},
51
55
"scripts" : {
52
56
"test" : " ava" ,
Original file line number Diff line number Diff line change
1
+ import { persistentReducer } from 'redux-pouchdb' ;
1
2
import {
2
3
PROGRESS_LOAD , COMPLETE_PAGE , COMPLETE_CHAPTER , COMPLETE_TUTORIAL
3
4
} from '../../actions/_types' ;
@@ -18,7 +19,7 @@ const _progress: CR.Progress = {
18
19
} ]
19
20
} ;
20
21
21
- export default function progressReducer (
22
+ function progressReducer (
22
23
progress = _progress , action : Action
23
24
) : CR . Progress {
24
25
switch ( action . type ) {
@@ -53,3 +54,4 @@ export default function progressReducer(
53
54
return progress ;
54
55
}
55
56
}
57
+ export default persistentReducer ( progressReducer ) ;
Original file line number Diff line number Diff line change 1
- import { createStore } from 'redux' ;
1
+ const env = 'dev' ;
2
+
3
+ import { createStore , compose , applyMiddleware } from 'redux' ;
4
+ import thunk from 'redux-thunk' ;
5
+ import * as PouchDB from 'pouchdb' ;
6
+ import { persistentStore } from 'redux-pouchdb' ;
2
7
import reducer from '../reducers' ;
3
8
4
- export let store : Redux . Store = createStore ( reducer , { } ) ;
9
+ const db = new PouchDB ( 'coderoad' ) ;
10
+
11
+ const middlewares = [ thunk ] ;
12
+
13
+ if ( env && env === 'dev' ) {
14
+ const createLogger = require ( 'redux-logger' ) ;
15
+ const logger = createLogger ( ) ;
16
+ middlewares . push ( logger ) ;
17
+ }
18
+
19
+ const createStoreWithMiddleware = compose (
20
+ applyMiddleware ( ...middlewares ) ,
21
+ persistentStore ( db )
22
+ ) ( createStore ) ;
23
+
24
+ export let store : Redux . Store = createStoreWithMiddleware ( reducer , { } ) ;
You can’t perform that action at this time.
0 commit comments