Kaynağa Gözat

fixed some problems in project.

Tomi Cvetic 8 yıl önce
ebeveyn
işleme
a911776758
3 değiştirilmiş dosya ile 14 ekleme ve 7 silme
  1. 9 4
      src/project/state.js
  2. 4 2
      src/redux-gen/basic.js
  3. 1 1
      src/redux-gen/crud.js

+ 9 - 4
src/project/state.js

@@ -10,12 +10,12 @@
 
 import combineReducers from 'redux'
 import reduxCrudGen from 'redux-gen/crud'
-import reduxBasicGen from 'redux-gen/basic'
+import reduxGen from 'redux-gen/basic'
 import { NAME, DATA } from './constants'
 // import { call, put, takeEvery } from 'redux-saga/effects'
 
-const basic = reduxBasicGen()
-const crud = reduxCrudGen()
+const basic = reduxGen(NAME)
+const crud = reduxCrudGen(NAME)
 
 /** actionTypes define what actions are handeled by the reducer. */
 const actions = { ...basic.actions, ...crud.actions }
@@ -27,7 +27,12 @@ export const state = [ ...basic.state, ...crud.state ]
 console.log('State state', state)
 
 /** reducer is called by the redux dispatcher and handles all component actions */
-export const reducer = combineReducers(basic.reducer, crud.reducer)
+export function reducer (state = [], action) {
+  let nextState
+  nextState = basic.reducer(state, action)
+  nextState = crud.reducer(nextState, action)
+  return nextState
+}
 
 /** sagas are asynchronous workers (JS generators) to handle the state. */
 export const workers = crud.workers

+ 4 - 2
src/redux-gen/basic.js

@@ -3,7 +3,7 @@
   * it outputs a state, action types, action creators, reducer, workers and watchers
   * to handle a restful API.
   */
-export function reduxGen (name) {
+export default function reduxGen (name) {
   const actionTypes = {}
   const actions = {}
 
@@ -40,6 +40,8 @@ export function reduxGen (name) {
     actionTypes,
     actions,
     state,
-    reducer
+    reducer,
+    watchers: null,
+    workers: null
   }
 }

+ 1 - 1
src/redux-gen/crud.js

@@ -88,7 +88,7 @@ export function crudLocalstorageApi (action, options) {
   *
   * Generates CRUD action types, actions, reducers, workers and watchers.
   */
-export function reduxCrudGen (name, prefix, api) {
+export default function reduxCrudGen (name, prefix, api) {
   const actionTypes = {}
   const actions = {}