JSFiddle - React, Tailwind, and code Playground

Basic YUI Module Add a basic YUI module (t-rabbits) and use it afterwards!

by David Iglesias

JavaScript

// Build adds the boilerplate for you
YUI.add('t-rabbits', function(Y) {
    // Create the namespace object for all our Rabbit examples
    Y.namespace('Rabbits');

    // Define our RegularRabbit class        
    Y.Rabbits.RegularRabbit = function(name) {
        this.name = name;
        document.write('<p>Created RegularRabbit: ' + this.name + '</p>');
    };

    // Let it speak!
    Y.Rabbits.RegularRabbit.prototype.speak = function(what) {
        document.write('<blockquote>' + this.name + ' says: ' + what + '</blockquote>');
    };
});

// Somewhere else, we can use our t-rabbits module!
YUI().use('t-rabbits', function(Y) {
    var myRabbit = new Y.Rabbits.RegularRabbit('Roger');
    myRabbit.speak('Hi Tuenti!');
});