Created
September 13, 2015 16:22
-
-
Save nakamura-to/c1c18dee82cabb8bc62d to your computer and use it in GitHub Desktop.
type definitions for Redux applyMiddleware
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
type action = { | |
type: string; | |
}; | |
type reducer = (state: any, action: action) => any; | |
type listener = () => void; | |
type dispatch = (action: action) => action; | |
type subscribe = (listener: listener) => void; | |
type getState = () => any; | |
type replaceReducer = (reducer: reducer) => reducer; | |
type store = { | |
dispatch: dispatch; | |
subscribe: subscribe; | |
getState: getState; | |
replaceReducer: replaceReducer; | |
} | |
type middlewareAPI = { | |
getState: getState, | |
dispatch: dispatch | |
}; | |
type middleware = (store: middlewareAPI) => (next: dispatch) => (action: action) => action; | |
type createStore = (reducer: reducer, initialState: any) => store; | |
// https://github.com/rackt/redux/blob/v3.0.0/src/utils/applyMiddleware.js | |
type applyMiddleware = (...middlewares : middleware[]) => ((createStore: createStore) => createStore); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment