store.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import {applyMiddleware, combineReducers, createStore} from "redux";
  2. import {authReducer} from "./authReducer";
  3. import {promiseReducer,promiseWatcher} from "./promiseReducer";
  4. import {routeReducer, routeWatcher} from "./routeReducer";
  5. import {playerReducer} from "./playerReducer";
  6. import {fullLoginWatcher,regWatcher} from "../actions/login-reg-actions";
  7. import {playlistFindByOwnerWatcher} from "../actions/find-actions";
  8. import {setAvatarWatcher} from "../actions/set-avatar-actions";
  9. import {
  10. fullUploadPlaylistsWatcher,
  11. playlistByIdWatcher,
  12. setTrackToPlaylistWatcher
  13. } from "../actions/my-playlist-tracks-actions";
  14. import {aboutMeWatcher,actionAboutMe} from "../actions/about-me-actions";
  15. import {trackPlayWatcher,trackStopWatcher,setPlaylistWatcher,trackVolumeWatcher,trackLoadWatcher,
  16. nextTrackWatcher,previousTrackWatcher,
  17. // trackCurrentTimeWatcher,
  18. } from "./playerReducer";
  19. import {localStoredReducer} from "./localStoredReducer";
  20. import createSagaMiddleware from 'redux-saga';
  21. import {all} from 'redux-saga/effects';
  22. import {createPlaylistWatcher} from "../actions/my-playlist-tracks-actions";
  23. // import {setUserPasswordWatcher} from "../pages/header/header-build";
  24. const sagaMiddleware = createSagaMiddleware()
  25. export const store = createStore(combineReducers({promise: localStoredReducer(promiseReducer, 'promise'),
  26. auth: localStoredReducer(authReducer, 'auth'),
  27. player: localStoredReducer(playerReducer, 'player'),
  28. route: localStoredReducer(routeReducer,'route')}),
  29. applyMiddleware(sagaMiddleware))
  30. // export const store = createStore(combineReducers({promise: promiseReducer,
  31. // auth: authReducer}),
  32. // applyMiddleware(sagaMiddleware))
  33. function* rootSaga(){
  34. yield all([
  35. promiseWatcher(),
  36. fullLoginWatcher(),
  37. regWatcher(),
  38. setAvatarWatcher(),
  39. aboutMeWatcher(),
  40. createPlaylistWatcher(),
  41. routeWatcher(),
  42. playlistFindByOwnerWatcher(),
  43. setTrackToPlaylistWatcher(),
  44. fullUploadPlaylistsWatcher(),
  45. setPlaylistWatcher(),
  46. trackPlayWatcher(),
  47. trackStopWatcher(),
  48. trackVolumeWatcher(),
  49. trackLoadWatcher(),
  50. nextTrackWatcher(),
  51. previousTrackWatcher(),
  52. playlistByIdWatcher()
  53. // trackCurrentTimeWatcher(),
  54. // setUserPasswordWatcher(),
  55. ])
  56. }
  57. store.dispatch(actionAboutMe())
  58. sagaMiddleware.run(rootSaga)
  59. store.subscribe(() => console.log(store.getState()))