var AppDispatcher = require('../../shared/dispatcher/AppDispatcher');
var EventEmitter = require('events').EventEmitter;

var INCREASE = 'IncreaseProductEvent';
var DENCREASE = 'DecreaseProductEvent';
var PRODUCT_QUANTITY_WAS_CHANGED = 'wasChangedEvent';

function increaseProduct(productId) {
    // Actually increases product and gets back the product with
    // the updated quntity
    CartStore.publish(PRODUCT_QUANTITY_WAS_CHANGED, productAfterUpdate);
}

var CartStore = assign({}, EventEmitter.prototype, {
    /* Publisher */
     publish: function (eventName, data) {
        this.emit(eventName, data);
    },
    /* Event Handlers */
    addOnProductWasAddedToCartListner: function(callback){
        this.on(PRODUCT_QUANTITY_WAS_CHANGED, callback);
    },
     removeOnProductWasAddedToCartListner: function(callback){
        this.on(PRODUCT_QUANTITY_WAS_CHANGED, callback);
    }
});

AppDispatcher.register(function (action) {
    switch (action.actionType) {
        case INCREASE:
            increaseProduct(action.productId);
            break;
        case DENCREASE:
            // Decrease..
            break;
        default:
            // no op
    }
});

module.exports = CartStore;
Rerun