index.js 1.9 KB

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