foundation-redux.thunkdispatch
Home > @genesislcap/foundation-redux > ThunkDispatch
ThunkDispatch type
Type for thunk actions that can be dispatched to the store.
Signature:
export type ThunkDispatch<S extends SliceArray> = ThunkAction<void, RootStateFromSlices<S>, any, Action>;
References: SliceArray, RootStateFromSlices
Remarks
This type represents thunk actions that can access the store's dispatch and getState functions. Thunks are useful for handling asynchronous operations and complex logic.
Example
const fetchUserThunk: ThunkDispatch<typeof slices> = (dispatch, getState) => {
fetch('/api/user').then(user => dispatch(actions.user.setUser(user)));
};