コード例 #1
0
ファイル: init.js プロジェクト: 403177368/all
  return dispatch => {
    Promise.all([

      api.fetchCart(),
      api.getItems(),
      api.getHomeSwiper()
    ]).then(res => {
      dispatch({
        type: 'INIT',
        user: {},
        shoppingCart: res[0],
        items: res[1],
        homeSwiper: res[2]
      });
    });
  };
コード例 #2
0
ファイル: item.js プロジェクト: 403177368/all
 return dispatch => {
   api.getItem(id).then(item => {
     dispatch({
       type: 'SET_ITEM',
       item
     });
   });
 };
コード例 #3
0
ファイル: index.js プロジェクト: 403177368/all
import axios from 'axios';

import api from 'api/api.js';
import {
  hashHistory
} from 'react-router';

export default {
  state: {},
  creators: {
    init({ dispatch }) {
      Promise.all([
        api.fetchCart(),
        api.getItems(),
        api.getHomeSwiper()
      ]).then(res => {
        dispatch({
          type: 'INIT',
          user: {},
          shoppingCart: res[0],
          items: res[1],
          homeSwiper: res[2]
        });
      });
    }
  }
};
コード例 #4
0
ファイル: main.js プロジェクト: atarss/chisakiPlayer
var server = require("api/api.js");

var api  = new server();
api.bindWorker("/", function(httpResp){
    httpResp.end("Hello, World~");
});

api.startServer(18000, "0.0.0.0");
コード例 #5
0
ファイル: store.js プロジェクト: 403177368/all
   price: 0
 }, action) {
   switch (action.type) {
   case 'SET_ITEM':
     var new_state = JSON.parse(JSON.stringify(state));
     for (var key in action.item) {
       new_state[key] = action.item[key];
     }
     return new_state;
   default:
     return state;
   }
 },
 creators: {
   fetch_item({ dispatch }, id) {
     api.getItem(id).then(item => {
       dispatch({
         type: 'SET_ITEM',
         item
       });
     });
   },
   addToCart({ dispatch }, item) {
     new Promise((resolve, reject) => {
       if (sessionStorage.shoppingCart) {
         var shoppingCart = JSON.parse(sessionStorage.shoppingCart);
         shoppingCart.push(item);
         sessionStorage.shoppingCart = JSON.stringify(shoppingCart);
       } else {
         sessionStorage.shoppingCart = '[]';
       }