JSFiddle - React, Tailwind, and code Playground

by ifandelse

JavaScript

window.postal = { channel: function () {} };

(function (root, factory) {
  if(typeof module === "object" && module.exports) {
    module.exports = factory(require("postal"));
  } else if(typeof define === "function" && define.amd) {
    define(["postal"], factory);
  } else {
    root.myModule = factory(root.postal);
  }
}(this, function(postal) {
  var sub;
  var ch = postal.channel("myModule");
  var myModule = {
    sayHi:function() {
      ch.publish("hey.yall", { msg: "myModule sez hai" });
    },
    dispose: function() {
      sub.unsubscribe();
    }
  };
  return myModule;
}));