JSFiddle - React, Tailwind, and code Playground

by samdelagarza

JavaScript

// core/metrics.js
// one way
define(function () {
    return {
        track: function () {
            if (inProduction && logToMixPanel) {
                mixpanel.track.apply(arguments);
            }
        }
    };
});

// core/metrics.js
// a smarter alternative
define(function () {
    var CoreMetrics = function () {};

    coreMetrics.prototype.track = function () {
        mixpanel.track.apply(arguments);
    };

    if (!inProduction && !logToMixPanel) {
        coreMetrics.prototype.track = function () {};
    }

    return new CoreMetrics();
});

// core/main.js
define(['./metrics.js'], function (metrics) {: : ts.core.metrics = metrics;: :
}

// someViewModel.js
define(['core'], function (core) {

    var m = core.metrics;

    m.track('eventName', {});
}