|
|
@ -5,6 +5,8 @@ import { createStore, applyMiddleware } from "redux";
|
|
|
|
import { persistStore } from "redux-persist";
|
|
|
|
import { persistStore } from "redux-persist";
|
|
|
|
import thunkMiddleware from "redux-thunk";
|
|
|
|
import thunkMiddleware from "redux-thunk";
|
|
|
|
import { createLogger } from "redux-logger";
|
|
|
|
import { createLogger } from "redux-logger";
|
|
|
|
|
|
|
|
import { ActionMeta } from "redux-actions";
|
|
|
|
|
|
|
|
import { useDispatch } from "react-redux";
|
|
|
|
|
|
|
|
|
|
|
|
import promiseMiddleware from "./promise-middleware";
|
|
|
|
import promiseMiddleware from "./promise-middleware";
|
|
|
|
|
|
|
|
|
|
|
@ -23,6 +25,13 @@ if (process.env.NODE_ENV === "development") {
|
|
|
|
middleware.push(createLogger());
|
|
|
|
middleware.push(createLogger());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function useAsyncDispatch() {
|
|
|
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
|
|
|
return function asyncDispatch<T, V>(action: ActionMeta<Promise<T>, V>): Promise<ActionMeta<T, V>> {
|
|
|
|
|
|
|
|
return dispatch(action) as any;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const store = createStore(
|
|
|
|
export const store = createStore(
|
|
|
|
reducers,
|
|
|
|
reducers,
|
|
|
|
applyMiddleware(...middleware)
|
|
|
|
applyMiddleware(...middleware)
|
|
|
|