JSFiddle - React, Tailwind, and code Playground

by dougneiner

HTML

<script src="https://raw.github.com/a2labs/riveter/master/lib/riveter.js"></script>

JavaScript

var Model1 = Backbone.Model.extend({
    observe: {
        "one": "1"
    }
});

var ObserveMixin = {
    _preInit: function () {
        this.setup();
    },
    mixin: {
        setup: function () {
            var toObserve = [ this.observe ];
			var _constructor = this.constructor;
			while( _constructor.__super__ ) {
				if ( _constructor.__super__.hasOwnProperty( "observe" ) ) {
					toObserve.unshift( _constructor.__super__.observe );
				}
				_constructor = _constructor.__super__.constructor;
			}
			toObserve.unshift( {} );
			this.observe = _.extend.apply( _, toObserve );
        }
    }
};

Model1 = riveter.compose( Model1, ObserveMixin );

var Model2 = Model1.extend({
    observe: {
        "two": "2"
    }
});

var Model3 = Model2.extend({
    observe: {
        "three": "3"
    }
});

var m3 = new Model3();
console.log( m3.observe );