JSFiddle - React, Tailwind, and code Playground

by ifandelse

JavaScript

// this is super naive and is mutating the instance
// that's being passed in, so be warned!
var ThingyFactory = function(amqpThing) {
    var Thingy = function() {};
    
    Thingy.prototype = amqpThing;
    
    Thingy.prototype.doThingyStuff = function() {
        console.log("I did Thingy Stuff!");    
    };
    
    return new Thingy();
};

var amqpLibThing = Object.create({
    doAmqpStuff: function() {
         console.log("I DID AMQP STUFF YAY!");   
    }
});

var thingy = ThingyFactory(amqpLibThing);

thingy.doAmqpStuff();
thingy.doThingyStuff();