redux-thunk
- Version 3.1.0
- Published
- 26.8 kB
- No dependencies
- MIT license
Install
npm i redux-thunk
yarn add redux-thunk
pnpm add redux-thunk
Overview
Thunk middleware for Redux.
Index
Variables
Functions
Interfaces
Type Aliases
Variables
variable thunk
const thunk: Middleware< ThunkDispatch<State, ExtraThunkArg, BasicAction>, State, ThunkDispatch<State, ExtraThunkArg, BasicAction>>;
variable withExtraArgument
const withExtraArgument: < State = any, BasicAction extends Action = AnyAction, ExtraThunkArg = undefined>( extraArgument?: ExtraThunkArg) => Middleware< ThunkDispatch<State, ExtraThunkArg, BasicAction>, State, ThunkDispatch<State, ExtraThunkArg, BasicAction>>;
Functions
function createThunkMiddleware
createThunkMiddleware: < State = any, BasicAction extends Action = AnyAction, ExtraThunkArg = undefined>( extraArgument?: ExtraThunkArg) => Middleware< ThunkDispatch<State, ExtraThunkArg, BasicAction>, State, ThunkDispatch<State, ExtraThunkArg, BasicAction>>;
A function that accepts a potential "extra argument" value to be injected later, and returns an instance of the thunk middleware that uses that value
Interfaces
interface ThunkDispatch
interface ThunkDispatch<State, ExtraThunkArg, BasicAction extends Action> {}
The dispatch method as modified by React-Thunk; overloaded so that you can dispatch: - standard (object) actions:
dispatch()
returns the action itself - thunk actions:dispatch()
returns the thunk's return valueState The redux state ExtraThunkArg The extra argument passed to the inner function of thunks (if specified when setting up the Thunk middleware) BasicAction The (non-thunk) actions that can be dispatched.
call signature
<ReturnType>( thunkAction: ThunkAction<ReturnType, State, ExtraThunkArg, BasicAction>): ReturnType;
Accepts a thunk function, runs it, and returns whatever the thunk itself returns
call signature
<Action extends BasicAction>(action: Action): Action;
Accepts a standard action object, and returns that action object
call signature
<ReturnType, Action extends BasicAction>( action: Action | ThunkAction<ReturnType, State, ExtraThunkArg, BasicAction>): Action | ReturnType;
A union of the other two overloads for TS inference purposes
Type Aliases
type ThunkAction
type ThunkAction<ReturnType, State, ExtraThunkArg, BasicAction extends Action> = ( dispatch: ThunkDispatch<State, ExtraThunkArg, BasicAction>, getState: () => State, extraArgument: ExtraThunkArg) => ReturnType;
A "thunk" action (a callback function that can be dispatched to the Redux store.)
Also known as the "thunk inner function", when used with the typical pattern of an action creator function that returns a thunk action.
ReturnType The return type of the thunk's inner function State The redux state ExtraThunkArg Optional extra argument passed to the inner function (if specified when setting up the Thunk middleware) BasicAction The (non-thunk) actions that can be dispatched.
type ThunkActionDispatch
type ThunkActionDispatch< ActionCreator extends (...args: any[]) => ThunkAction<any, any, any, any>> = (...args: Parameters<ActionCreator>) => ReturnType<ReturnType<ActionCreator>>;
A generic type that takes a thunk action creator and returns a function signature which matches how it would appear after being processed using bindActionCreators(): a function that takes the arguments of the outer function, and returns the return type of the inner "thunk" function.
ActionCreator Thunk action creator to be wrapped
type ThunkMiddleware
type ThunkMiddleware< State = any, BasicAction extends Action = AnyAction, ExtraThunkArg = undefined> = Middleware< ThunkDispatch<State, ExtraThunkArg, BasicAction>, State, ThunkDispatch<State, ExtraThunkArg, BasicAction>>;
State The redux state BasicAction The (non-thunk) actions that can be dispatched ExtraThunkArg An optional extra argument to pass to a thunk's inner function. (Only used if you call
withExtraArgument()
)
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (11)
Peer Dependencies (1)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/redux-thunk
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/redux-thunk)
- HTML<a href="https://www.jsdocs.io/package/redux-thunk"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3338 ms. - Missing or incorrect documentation? Open an issue for this package.