Skip to content
Snippets Groups Projects
Unverified Commit 4e6d61ec authored by Nicolò Pretto's avatar Nicolò Pretto Committed by GitHub
Browse files

type createThunkAction to avoid it leaking anys in all the codebase (#35784)

parent ba7543a4
Branches
Tags
No related merge requests found
import { createAsyncThunk as createAsyncThunkOriginal } from "@reduxjs/toolkit";
import type { State } from "metabase-types/store";
import type { State, Dispatch, GetState } from "metabase-types/store";
import { withAction } from "./utils";
interface ThunkConfig {
state: State;
......@@ -7,3 +8,14 @@ interface ThunkConfig {
export const createAsyncThunk =
createAsyncThunkOriginal.withTypes<ThunkConfig>();
// similar to createAction but accepts a (redux-thunk style) thunk and dispatches based on whether
// the promise returned from the thunk resolves or rejects, similar to redux-promise
export function createThunkAction<TArgs extends any[]>(
actionType: string,
thunkCreator: (
...args: TArgs
) => (dispatch: Dispatch, getState: GetState) => any,
): (...args: TArgs) => any {
return withAction(actionType)(thunkCreator);
}
......@@ -19,12 +19,6 @@ import { delay } from "metabase/lib/promise";
export { combineReducers, compose } from "@reduxjs/toolkit";
export { handleActions, createAction } from "redux-actions";
// similar to createAction but accepts a (redux-thunk style) thunk and dispatches based on whether
// the promise returned from the thunk resolves or rejects, similar to redux-promise
export function createThunkAction(actionType, thunkCreator) {
return withAction(actionType)(thunkCreator);
}
// turns string timestamps into moment objects
export function momentifyTimestamps(
object,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment