File: app/components/test-shopping-cart/api/shop.js

Recommend this page to a friend!
  Classes of Sergey Beskorovayniy   Vuex Examples   app/components/test-shopping-cart/api/shop.js   Download  
File: app/components/test-shopping-cart/api/shop.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/api/shop.js
Date: 2 years ago
Size: 806 bytes
 

Contents

Class file image Download
define([], function () { // initial state var _products = [ {"id": 1, "title": "iPad 4 Mini", "price": 500.01, "inventory": 2}, {"id": 2, "title": "H&M T-Shirt White", "price": 10.99, "inventory": 10}, {"id": 3, "title": "Charli XCX - Sucker CD", "price": 19.99, "inventory": 5} ]; var getProducts = function (cb) { return setTimeout(function () { cb(_products) }, 100); }; var buyProducts = function (products, cb, errorCb) { return setTimeout(function () { (Math.random() > 0.5 || navigator.userAgent.indexOf('PhantomJS') > -1) ? cb() : errorCb(); }, 100); }; return { getProducts: getProducts, buyProducts: buyProducts } });