Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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);
return state;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment