Last active
August 8, 2019 20:16
-
-
Save codeBelt/1052b8e11b3b384ee42518a0a8ccfa39 to your computer and use it in GitHub Desktop.
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
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