Last active
October 5, 2017 12:35
-
-
Save kobvel/2cd189880378f1af0aa9d06269ba1a91 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { Store } from '@ngrx/store'; | |
import * as actions from './profile.actions'; | |
export interface IProfileState { | |
// define interface for data you expect to get from server | |
// or just set type to any | |
profileData: IProfileData; | |
} | |
export const initialState: IProfileState = { | |
profileData: null | |
}; | |
export function reducer( | |
state: IProfileState = initialState, | |
action: actions.Actions | |
): IProfileState { | |
switch (action.type) { | |
// Create new state object by coping old state | |
// and extending with the new data | |
case actions.ActionTypes.UPDATE: | |
return Object.assign({}, state, { | |
profileData: action.payload | |
}); | |
default: | |
return state; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment