/**
 * @license http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 * @author Phuong LE <phuong.le@menincode.com> <@>
 * @copyright Copyright (c) 2021 Menincode (https://www.menincode.com)
 */

/** MyNamespace_MyModule/js/catalog-add-to-cart-mixin.js */

define(['jquery'], function ($) {
    'use strict';

    var targetWidgetMixin = {
        options: {
            minicartSelector: '[data-block="minicart"]', // override an existing option
            customLoader : false , // add new option
        },

        /** Alter an existing function **/
        isLoaderEnabled: function () {
            
            if (!this.options.customLoader) {
               // Do Something
                
                /** Access to an existing option */
                if (this.options.processStart) {
                    // Do Something
                }
                
            } else {
                return this._super();
            }
        }
    };

    return function (targetWidget) {
        
        $.widget('mage.catalogAddToCart', targetWidget, targetWidgetMixin);

        return $.mage.catalogAddToCart; //  the widget by parent alias should be returned
    };
});