index.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import { createStore, combineReducers, applyMiddleware } from 'redux'
  2. import thunk from 'redux-thunk'
  3. import { promiseReducer } from './reducers/promiseReducer'
  4. import { authReducer } from './reducers/authReducer'
  5. import { myProfileReducer } from './reducers/myProfileReducer'
  6. import { userProfileReducer } from './reducers/userProfileReducer'
  7. import { feedReducer } from './reducers/feedReducer'
  8. import { postReducer } from './reducers/postReducer'
  9. import { exploreReducer } from './reducers/exploreReducer'
  10. import {
  11. promiseWatcher,
  12. fullProfilePageWatcher,
  13. loginWatcher,
  14. fullPageAboutUserWatcher,
  15. feedWatcher,
  16. exploreWatcher,
  17. onePostWatcher,
  18. addCommentFeedWatcher,
  19. addCommentOnePostWatcher,
  20. changeLikePostWatcher,
  21. editPostWatcher,
  22. changeSubscribeWatcher,
  23. userUpdateWatcher,
  24. setAvatarWatcher,
  25. clearAllDataWatcher,
  26. registerWatcher,
  27. postsWatcher,
  28. addSubCommentWatcher,
  29. getSubCommentWatcher,
  30. changeLikePostFeedWatcher
  31. } from './saga'
  32. import createSagaMiddleware from 'redux-saga' //функция по созданию middleware
  33. import {
  34. all,
  35. put,
  36. takeEvery,
  37. takeLatest,
  38. takeLeading,
  39. select,
  40. } from 'redux-saga/effects' //
  41. const sagaMiddleware = createSagaMiddleware()
  42. export const store = createStore(
  43. combineReducers({
  44. promise: promiseReducer,
  45. auth: authReducer,
  46. myData: myProfileReducer,
  47. userData: userProfileReducer,
  48. feed: feedReducer,
  49. post: postReducer,
  50. explore: exploreReducer,
  51. }),
  52. applyMiddleware(sagaMiddleware),
  53. )
  54. function* rootSaga() {
  55. yield all([
  56. promiseWatcher(),
  57. fullProfilePageWatcher(),
  58. loginWatcher(),
  59. registerWatcher(),
  60. fullPageAboutUserWatcher(),
  61. feedWatcher(),
  62. exploreWatcher(),
  63. onePostWatcher(),
  64. addCommentOnePostWatcher(),
  65. changeLikePostWatcher(),
  66. editPostWatcher(),
  67. changeSubscribeWatcher(),
  68. userUpdateWatcher(),
  69. setAvatarWatcher(),
  70. clearAllDataWatcher(),
  71. postsWatcher(),
  72. addCommentFeedWatcher(),
  73. addSubCommentWatcher(),
  74. getSubCommentWatcher(),
  75. changeLikePostFeedWatcher()
  76. // addCommentFeedWatcher()
  77. ])
  78. }
  79. sagaMiddleware.run(rootSaga)