Last active
July 25, 2017 18:17
-
-
Save pronebird/68a43881ff5774c6095ce14a9e51460f to your computer and use it in GitHub Desktop.
Patch that adds Dispatch parameter to redux interface
This file contains hidden or 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
// flow-typed signature: 7f1a115f75043c44385071ea3f33c586 | |
// flow-typed version: 358375125e/redux_v3.x.x/flow_>=v0.33.x | |
declare module 'redux' { | |
/* | |
S = State | |
A = Action | |
D = Dispatch | |
*/ | |
declare type Dispatch<A: { type: $Subtype<string> }> = (action: A) => A; | |
declare type MiddlewareAPI<S, A, D> = { | |
dispatch: D; | |
getState(): S; | |
}; | |
declare type Store<S, A, D> = { | |
// rewrite MiddlewareAPI members in order to get nicer error messages (intersections produce long messages) | |
dispatch: D; | |
getState(): S; | |
subscribe(listener: () => void): () => void; | |
replaceReducer(nextReducer: Reducer<S, A>): void | |
}; | |
declare type Reducer<S, A> = (state: S, action: A) => S; | |
declare type CombinedReducer<S, A> = (state: $Shape<S> & {} | void, action: A) => S; | |
declare type Middleware<S, A, D> = | |
(api: MiddlewareAPI<S, A, D>) => | |
(next: D) => D; | |
declare type StoreCreator<S, A> = { | |
(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<S, A>): Store<S, A>; | |
(reducer: Reducer<S, A>, preloadedState: S, enhancer?: StoreEnhancer<S, A>): Store<S, A>; | |
}; | |
declare type StoreEnhancer<S, A> = (next: StoreCreator<S, A>) => StoreCreator<S, A>; | |
declare function createStore<S, A, D>(reducer: Reducer<S, A>, enhancer?: StoreEnhancer<S, A>): Store<S, A, D>; | |
declare function createStore<S, A, D>(reducer: Reducer<S, A>, preloadedState: S, enhancer?: StoreEnhancer<S, A>): Store<S, A, D>; | |
declare function applyMiddleware<S, A, D>(...middlewares: Array<Middleware<S, A, D>>): StoreEnhancer<S, A>; | |
declare type ActionCreator<A, B> = (...args: Array<B>) => A; | |
declare type ActionCreators<K, A> = { [key: K]: ActionCreator<A, any> }; | |
declare function bindActionCreators<A, C: ActionCreator<A, any>, D>(actionCreator: C, dispatch: D): C; | |
declare function bindActionCreators<A, K, C: ActionCreators<K, A>, D>(actionCreators: C, dispatch: D): C; | |
declare function combineReducers<O: Object, A>(reducers: O): CombinedReducer<$ObjMap<O, <S>(r: Reducer<S, any>) => S>, A>; | |
declare function compose<S, A>(...fns: Array<StoreEnhancer<S, A>>): Function; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment