forked from reduxjs/redux-thunk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
declare own Dispatch and Store interfaces
The current implementation of the typings makes it impossible to create a middleware that only handles standard actions. This means a middleware must handle thunked actions even though it never actually handles them during runtime. (see issue and examples in reduxjs#82) By declaring the Dispatch and Store interfaces again instead of overloading the original implementation of redux a consumer of redux-thunk can choose the right implementation for his use case (e.g. ActionCreator vs. Middleware). fixes reduxjs#82
- Loading branch information
Hendrik Liebau
committed
Jul 7, 2016
1 parent
00cc012
commit 3178815
Showing
2 changed files
with
15 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import {Middleware, Dispatch} from "redux"; | ||
import { Action, Middleware, Dispatch as ReduxDispatch, Store as ReduxStore } from "redux"; | ||
|
||
|
||
export type ThunkAction<R, S, E> = (dispatch: Dispatch<S>, getState: () => S, | ||
extraArgument: E) => R; | ||
|
||
declare module "redux" { | ||
export interface Dispatch<S> { | ||
export interface Dispatch<S> extends ReduxDispatch<S> { | ||
<R, E>(asyncAction: ThunkAction<R, S, E>): R; | ||
} | ||
} | ||
|
||
export interface Store<S> extends ReduxStore<S> { | ||
dispatch: Dispatch<S>; | ||
} | ||
|
||
export type ThunkAction<R, S, E> = (dispatch: Dispatch<S>, getState: () => S, | ||
extraArgument: E) => R; | ||
|
||
declare const thunk: Middleware & { | ||
withExtraArgument(extraArgument: any): Middleware; | ||
withExtraArgument(extraArgument: any): Middleware; | ||
}; | ||
|
||
export default thunk; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters