File: app/components/test-shopping-cart/store/modules/products.js

Recommend this page to a friend!
  Classes of Sergey Beskorovayniy   Vuex Examples   app/components/test-shopping-cart/store/modules/products.js   Download  
File: app/components/test-shopping-cart/store/modules/products.js
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Vuex Examples
Example apps using Vuex state management pattern
Author: By
Last change: Update of app/components/test-shopping-cart/store/modules/products.js
Date: 2 years ago
Size: 502 bytes
 

Contents

Class file image Download
define([], function () { // initial state var state = { all: [] }; var mutations = { RECEIVE_PRODUCTS: function (state, products) { state.all = products; }, ADD_TO_CART: function (state, id) { var findProduct = _.find(state.all, function (p) { return p.id === id; }); findProduct.inventory--; } }; return { state: state, mutations: mutations }; });