-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
The current types for ThunkDispatch
and ThunkAction
look like this:
export interface ThunkDispatch<S, E, A extends Action> {
<T extends A>(action: T): T;
<R>(asyncAction: ThunkAction<R, S, E, A>): R;
}
export type ThunkAction<R, S, E, A extends Action> = (
dispatch: ThunkDispatch<S, E, A>,
getState: () => S,
extraArgument: E
) => R;
In the second overload of ThunkDispatch
, the parameter is named asyncAction
. In my opinion, this name is misleading, because ThunkAction
does not have to be asynchronous. Using thunk for asynchronous actions is something you can do, but it also has some synchronous use cases -- e.g., as the README itself notes (emphases added), "The thunk can be used to delay the dispatch of an action, or to dispatch [even synchronously!] only if a certain condition is met." So, I'd like to recommend changing the name to just "thunkAction" (PR incoming!), in the hopes that will prevent some potential confusion.
Metadata
Metadata
Assignees
Labels
No labels