|
@@ -11,31 +11,38 @@
|
|
|
import combineReducers from 'redux'
|
|
|
import reduxCrudGen from 'redux-gen/crud'
|
|
|
import reduxGen from 'redux-gen/basic'
|
|
|
-import { NAME, DATA } from './constants'
|
|
|
-// import { call, put, takeEvery } from 'redux-saga/effects'
|
|
|
+import { NAME } from './constants'
|
|
|
|
|
|
+/**
|
|
|
+ *
|
|
|
+ */
|
|
|
+import http from 'crud-api/http'
|
|
|
+import localstorage from 'crud-api/localStorage'
|
|
|
const basic = reduxGen(NAME)
|
|
|
-const crud = reduxCrudGen(NAME)
|
|
|
+const db = reduxCrudGen(NAME, 'db', http)
|
|
|
+const local = reduxCrudGen(NAME, 'local', localstorage)
|
|
|
+console.log('basic, crud', basic, db, local)
|
|
|
|
|
|
/** actionTypes define what actions are handeled by the reducer. */
|
|
|
-const actions = { ...basic.actions, ...crud.actions }
|
|
|
+export const actions = { ...basic.actions, ...db.actions, ...local.actions }
|
|
|
console.log('State actions', actions)
|
|
|
|
|
|
/** state definition */
|
|
|
/** It is generally easier to not have another object here. */
|
|
|
-export const state = [ ...basic.state, ...crud.state ]
|
|
|
+export const state = { ...basic.state, ...db.state, ...local.state }
|
|
|
console.log('State state', state)
|
|
|
|
|
|
/** reducer is called by the redux dispatcher and handles all component actions */
|
|
|
export function reducer (state = [], action) {
|
|
|
- let nextState
|
|
|
- nextState = basic.reducer(state, action)
|
|
|
- nextState = crud.reducer(nextState, action)
|
|
|
+ let nextState = state
|
|
|
+ nextState = basic.reducer(nextState, action)
|
|
|
+ nextState = db.reducer(nextState, action)
|
|
|
+ nextState = local.reducer(nextState, action)
|
|
|
return nextState
|
|
|
}
|
|
|
|
|
|
/** sagas are asynchronous workers (JS generators) to handle the state. */
|
|
|
-export const workers = crud.workers
|
|
|
-
|
|
|
-// Watcher (intercepts INCREMENT_REQUEST, dispatches INCREMENT_SUCCESS or INCREMENT_FAIL in return.)
|
|
|
-export const watchers = crud.watchers
|
|
|
+export function * saga () {
|
|
|
+ yield db.saga()
|
|
|
+ yield local.saga()
|
|
|
+}
|