index.js 1.7 KB

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