Skip to content

Instantly share code, notes, and snippets.

@codeBelt
Last active August 8, 2019 20:16
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 codeBelt/1052b8e11b3b384ee42518a0a8ccfa39 to your computer and use it in GitHub Desktop.
Save codeBelt/1052b8e11b3b384ee42518a0a8ccfa39 to your computer and use it in GitHub Desktop.
import ISomeThingReducerState from './models/ISomeThingReducerState';
import IAction from '../IAction';
import SomeThingAction, {SomeThingActionUnion} from './SomeThingAction';
import OtherThingResponseModel from './models/OtherThingResponseModel';
export default class SomeThingReducer {
private static readonly _initialState: ISomeThingReducerState = {
isLoadingOtherThing: false,
otherThing: null,
};
public static reducer(state: ISomeThingReducerState = SomeThingReducer._initialState, action: IAction<SomeThingActionUnion>): ISomeThingReducerState {
switch (action.type) {
case SomeThingAction.LOAD_OTHER_THING:
return {
...state,
isLoadingOtherThing: true,
};
case SomeThingAction.LOAD_OTHER_THING_SUCCESS:
return {
...state,
isLoadingOtherThing: false,
otherThing: action.payload as OtherThingResponseModel,
};
default:
return state;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment