index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. } from './saga'
  29. import createSagaMiddleware from 'redux-saga' //функция по созданию middleware
  30. import {
  31. all,
  32. put,
  33. takeEvery,
  34. takeLatest,
  35. takeLeading,
  36. select,
  37. } from 'redux-saga/effects' //
  38. const sagaMiddleware = createSagaMiddleware()
  39. export const store = createStore(
  40. combineReducers({
  41. promise: promiseReducer,
  42. auth: authReducer,
  43. myData: myProfileReducer,
  44. userData: userProfileReducer,
  45. feed: feedReducer,
  46. post: postReducer,
  47. explore: exploreReducer,
  48. }),
  49. applyMiddleware(sagaMiddleware),
  50. )
  51. function* rootSaga() {
  52. yield all([
  53. promiseWatcher(),
  54. fullProfilePageWatcher(),
  55. loginWatcher(),
  56. registerWatcher(),
  57. fullPageAboutUserWatcher(),
  58. feedWatcher(),
  59. exploreWatcher(),
  60. onePostWatcher(),
  61. addCommentOnePostWatcher(),
  62. changeLikePostWatcher(),
  63. editPostWatcher(),
  64. changeSubscribeWatcher(),
  65. userUpdateWatcher(),
  66. setAvatarWatcher(),
  67. clearAllDataWatcher(),
  68. postsWatcher(),
  69. addCommentFeedWatcher()
  70. // addCommentFeedWatcher()
  71. ])
  72. }
  73. sagaMiddleware.run(rootSaga)