This repository was archived by the owner on Apr 8, 2020. It is now read-only.
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 11"use strict" ;
2+ var redux_pouchdb_1 = require ( 'redux-pouchdb' ) ;
23var _types_1 = require ( '../../actions/_types' ) ;
34var store_1 = require ( '../../store' ) ;
45var _progress = {
@@ -50,4 +51,4 @@ function progressReducer(progress, action) {
5051 }
5152}
5253Object . 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 11"use strict" ;
2+ var env = 'dev' ;
23var 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' ) ;
37var 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 4242 "highlights" : " 1.3.1" ,
4343 "marked" : " 0.3.5" ,
4444 "material-ui" : " 0.15.0-beta.2" ,
45+ "pouchdb" : " ^5.3.2" ,
4546 "react" : " 15.0.1" ,
4647 "react-dom" : " 15.0.1" ,
4748 "react-redux" : " 4.4.5" ,
4849 "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"
5054 },
5155 "scripts" : {
5256 "test" : " ava" ,
Original file line number Diff line number Diff line change 1+ import { persistentReducer } from 'redux-pouchdb' ;
12import {
23 PROGRESS_LOAD , COMPLETE_PAGE , COMPLETE_CHAPTER , COMPLETE_TUTORIAL
34} from '../../actions/_types' ;
@@ -18,7 +19,7 @@ const _progress: CR.Progress = {
1819 } ]
1920} ;
2021
21- export default function progressReducer (
22+ function progressReducer (
2223 progress = _progress , action : Action
2324) : CR . Progress {
2425 switch ( action . type ) {
@@ -53,3 +54,4 @@ export default function progressReducer(
5354 return progress ;
5455 }
5556}
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' ;
27import reducer from '../reducers' ;
38
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