store.js 2.5 KB

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