From 5bcb97c14f89ca96bbc7f53f8c4c79a4f6f26075 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Sat, 6 Oct 2018 14:06:18 -0700 Subject: [PATCH] Add more redux types --- js/store.ts | 13 ++++++++++--- js/types.ts | 13 +++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/js/store.ts b/js/store.ts index 050f91de..4ce82728 100644 --- a/js/store.ts +++ b/js/store.ts @@ -7,7 +7,14 @@ import { merge } from "./utils"; import { UPDATE_TIME_ELAPSED, STEP_MARQUEE } from "./actionTypes"; import Media from "./media"; import Emitter from "./emitter"; -import { Extras, MiddlewareStore, Dispatch, Action, AppState } from "./types"; +import { + Extras, + MiddlewareStore, + Dispatch, + Action, + AppState, + Middleware +} from "./types"; const compose = composeWithDevTools({ actionsBlacklist: [UPDATE_TIME_ELAPSED, STEP_MARQUEE] @@ -16,8 +23,8 @@ const compose = composeWithDevTools({ export default function( media: Media, actionEmitter: Emitter, - customMiddlewares = [], - stateOverrides: DeepPartial, + customMiddlewares: Middleware[] = [], + stateOverrides: DeepPartial | undefined, extras: Extras ) { let initialState; diff --git a/js/types.ts b/js/types.ts index 75565330..2a1c80c1 100644 --- a/js/types.ts +++ b/js/types.ts @@ -474,6 +474,19 @@ export interface DispatchObject { export type Dispatch = (action: Dispatchable) => void; +export type Reducer = (state: AppState, action: Action) => AppState; + +export type Middleware = ( + store: Store +) => (next: Dispatch) => (action: Action) => any; + +export interface Store { + subscribe(cb: () => void): () => void; + dispatch: Dispatch; + getState: GetState; + replaceReducer(reducer: Reducer): void; +} + export interface MiddlewareStore { dispatch: Dispatch; getState: GetState;