Skip to content

Instantly share code, notes, and snippets.

@cloudscape-germany
Created October 11, 2016 00:59
Show Gist options
  • Select an option

  • Save cloudscape-germany/5dc4026007a0c3ea3a4e0c15c0adfe05 to your computer and use it in GitHub Desktop.

Select an option

Save cloudscape-germany/5dc4026007a0c3ea3a4e0c15c0adfe05 to your computer and use it in GitHub Desktop.
import { ActionReducer, Action } from "@ngrx/store";
import { ActionType } from "./action-type";
import { PurchaseModel } from "../purchase/purchase.model";
export const currentPurchase: ActionReducer<PurchaseModel> = (state:PurchaseModel = new PurchaseModel(), action:Action) => {
switch (action.type) {
case ActionType.SET_PURCHASE:
return (action.payload !== null) ? action.payload : new PurchaseModel();
case ActionType.UPDATE_PURCHASE:
return Object.assign({}, state, action.payload);
default:
return state;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment