index.js 701 B

1234567891011121314151617181920212223
  1. import { createStore, combineReducers, applyMiddleware } from "redux";
  2. import thunk from "redux-thunk";
  3. import authReducer from "./auth";
  4. import promiseReducer from "./promise";
  5. import { actionSnippetFindByOwner } from "../actions/actionSnippetFindByOwner";
  6. import { actionFindUser } from "../actions/actionFindUser";
  7. let reducers = combineReducers({
  8. p: promiseReducer,
  9. a: authReducer
  10. })
  11. const store = createStore(reducers, applyMiddleware(thunk));
  12. store.subscribe(() => console.log(store.getState()));
  13. if (localStorage.authToken) {
  14. store.dispatch(actionFindUser());
  15. store.dispatch(
  16. actionSnippetFindByOwner(store.getState().a.payload.sub.id)
  17. );
  18. }
  19. export default store;