store.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 {loginWatcher,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 {fullUploadTrackWatcher} from "../actions/no-playlist-track-actions";
  12. import {localStoredReducer} from "./localStoredReducer";
  13. import createSagaMiddleware from 'redux-saga';
  14. import {all} from 'redux-saga/effects';
  15. import {createPlaylistWatcher} from "../actions/my-playlist-tracks-actions";
  16. // import {setUserPasswordWatcher} from "../pages/header/header-build";
  17. const sagaMiddleware = createSagaMiddleware()
  18. export const store = createStore(combineReducers({promise: localStoredReducer(promiseReducer, 'promise'),
  19. auth: localStoredReducer(authReducer, 'auth'),
  20. player: localStoredReducer(playerReducer, 'player'),
  21. route: localStoredReducer(routeReducer,'route')}),
  22. applyMiddleware(sagaMiddleware))
  23. // export const store = createStore(combineReducers({promise: promiseReducer,
  24. // auth: authReducer}),
  25. // applyMiddleware(sagaMiddleware))
  26. function* rootSaga(){
  27. yield all([
  28. promiseWatcher(),
  29. loginWatcher(),
  30. regWatcher(),
  31. setAvatarWatcher(),
  32. aboutMeWatcher(),
  33. createPlaylistWatcher(),
  34. findMyTracksWatcher(),
  35. routeWatcher(),
  36. playlistFindByOwnerWatcher(),
  37. setTrackToPlaylistWatcher(),
  38. fullUploadPlaylistsWatcher(),
  39. fullUploadTrackWatcher(),
  40. // setUserPasswordWatcher(),
  41. ])
  42. }
  43. store.dispatch(actionAboutMe())
  44. sagaMiddleware.run(rootSaga)
  45. store.subscribe(() => console.log(store.getState()))