Skip to content

Instantly share code, notes, and snippets.

@nakamura-to
Created September 13, 2015 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nakamura-to/c1c18dee82cabb8bc62d to your computer and use it in GitHub Desktop.
Save nakamura-to/c1c18dee82cabb8bc62d to your computer and use it in GitHub Desktop.
type definitions for Redux applyMiddleware
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