Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. import { combineReducers } from 'redux'
  2. import { createRootReducer as processModules } from 'redux-module-builder'
  3. import { routerReducer as routing, push } from 'react-router-redux'
  4. import { reducer as form } from 'redux-form'
  5.  
  6. /**
  7. * import your modules here
  8. * sample
  9. * import MyModule from './MyModule'
  10. */
  11.  
  12. /**
  13. * You can register your modules here
  14. * @type {Object}
  15. */
  16. const modules = {
  17. }
  18.  
  19. const initialActions = {
  20. routing: {
  21. navigateTo: path => dispatch => dispatch(push(path))
  22. }
  23. }
  24.  
  25. /**
  26. * You can add reducers from external npm modules
  27. * @type {Object}
  28. */
  29. const initialReducers = {
  30. form,
  31. routing
  32. }
  33.  
  34. const initialState = {}
  35.  
  36. /**
  37. * We are actually processing the modules why call createRootReducer if the function generates actions
  38. * @type {object}
  39. */
  40. const bundled = processModules(modules, {
  41. initialInitialState: initialState,
  42. initialActions,
  43. initialReducers
  44. })
  45.  
  46. const reducers = combineReducers(bundled.reducers)
  47.  
  48. /**
  49. * Function to activate the generated bundle
  50. * @return {object} reducers, actions, inititalState
  51. */
  52. export default () => {
  53. return {
  54. reducers,
  55. actions: bundled.actions,
  56. initialState: bundled.initialState
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement