From 2236a1a36db7f2d5caab352fe00d58c9ab004b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=A4ggmark?= Date: Wed, 30 Jan 2019 12:03:30 +0100 Subject: [PATCH] Minor change to Action interfaces --- public/app/core/redux/actionCreatorFactory.ts | 12 ++++++------ public/app/core/redux/reducerFactory.test.ts | 6 +++--- public/app/core/redux/reducerFactory.ts | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/public/app/core/redux/actionCreatorFactory.ts b/public/app/core/redux/actionCreatorFactory.ts index d6e33160d5f..fd12ac6ca36 100644 --- a/public/app/core/redux/actionCreatorFactory.ts +++ b/public/app/core/redux/actionCreatorFactory.ts @@ -2,23 +2,23 @@ import { Action } from 'redux'; const allActionCreators: string[] = []; -export interface GrafanaAction extends Action { +export interface ActionOf extends Action { readonly type: string; readonly payload: Payload; } -export interface GrafanaActionCreator { +export interface ActionCreator { readonly type: string; - (payload: Payload): GrafanaAction; + (payload: Payload): ActionOf; } export interface ActionCreatorFactory { - create: () => GrafanaActionCreator; + create: () => ActionCreator; } export const actionCreatorFactory = (type: string): ActionCreatorFactory => { - const create = (): GrafanaActionCreator => { - return Object.assign((payload: Payload): GrafanaAction => ({ type, payload }), { type }); + const create = (): ActionCreator => { + return Object.assign((payload: Payload): ActionOf => ({ type, payload }), { type }); }; if (allActionCreators.some(t => (t && type ? t.toLocaleUpperCase() === type.toLocaleUpperCase() : false))) { diff --git a/public/app/core/redux/reducerFactory.test.ts b/public/app/core/redux/reducerFactory.test.ts index 7e1d5e350e0..2d0acc93749 100644 --- a/public/app/core/redux/reducerFactory.test.ts +++ b/public/app/core/redux/reducerFactory.test.ts @@ -1,5 +1,5 @@ import { reducerFactory } from './reducerFactory'; -import { actionCreatorFactory, GrafanaAction } from './actionCreatorFactory'; +import { actionCreatorFactory, ActionOf } from './actionCreatorFactory'; interface DummyReducerState { n: number; @@ -37,7 +37,7 @@ describe('reducerFactory', () => { describe('when reducer is called with no state', () => { describe('and with an action that the handler can not handle', () => { it('then the resulting state should be intial state', () => { - const result = dummyReducer(undefined as DummyReducerState, {} as GrafanaAction); + const result = dummyReducer(undefined as DummyReducerState, {} as ActionOf); expect(result).toEqual(dummyReducerIntialState); }); @@ -56,7 +56,7 @@ describe('reducerFactory', () => { describe('when reducer is called with a state', () => { describe('and with an action that the handler can not handle', () => { it('then the resulting state should be intial state', () => { - const result = dummyReducer(dummyReducerIntialState, {} as GrafanaAction); + const result = dummyReducer(dummyReducerIntialState, {} as ActionOf); expect(result).toEqual(dummyReducerIntialState); }); diff --git a/public/app/core/redux/reducerFactory.ts b/public/app/core/redux/reducerFactory.ts index 9fcc52649e3..2df5217ea6e 100644 --- a/public/app/core/redux/reducerFactory.ts +++ b/public/app/core/redux/reducerFactory.ts @@ -1,9 +1,9 @@ -import { GrafanaAction, GrafanaActionCreator } from './actionCreatorFactory'; +import { ActionOf, ActionCreator } from './actionCreatorFactory'; import { Reducer } from 'redux'; export interface HandlerConfig { - filter: GrafanaActionCreator; - handler: (state: State, action: GrafanaAction) => State; + filter: ActionCreator; + handler: (state: State, action: ActionOf) => State; } export interface AddHandler { @@ -11,7 +11,7 @@ export interface AddHandler { } export interface CreateReducer extends AddHandler { - create: () => Reducer>; + create: () => Reducer>; } export const reducerFactory = (initialState: State): AddHandler => { @@ -27,8 +27,8 @@ export const reducerFactory = (initialState: State): AddHandler => return instance; }; - const create = (): Reducer> => { - const reducer: Reducer> = (state: State = initialState, action: GrafanaAction) => { + const create = (): Reducer> => { + const reducer: Reducer> = (state: State = initialState, action: ActionOf) => { const validHandlers = allHandlerConfigs .filter(config => config.filter.type === action.type) .map(config => config.handler);