Skip to content

Instantly share code, notes, and snippets.

@kobvel
Last active October 5, 2017 12:35
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 kobvel/2cd189880378f1af0aa9d06269ba1a91 to your computer and use it in GitHub Desktop.
Save kobvel/2cd189880378f1af0aa9d06269ba1a91 to your computer and use it in GitHub Desktop.
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