JSFiddle - React, Tailwind, and code Playground
JavaScript
var Device = new Class({
properties: ['top', 'left', 'width', 'height'],
_parameterStack: [],
initialize: function() {
this.createPropertyAccessors();
},
createPropertyAccessors: function() {
this.properties.each(function(property) {
Object.defineProperty(this, property, {
enumerable: true,
configurable: true,
set: function(value) {
var o = {};
o[property] = value;
this._parameterStack.push(o);
return this[property];
}.bind(this)
});
}.bind(this));
},
setLocation: function(top, left) {
this.top = top;
this.left = left;
},
setAspects: function(width, height) {
this.width = width;
this.height = height;
},
$: function(method, args) {
this[method].apply(this, args);
var argsStack = [];
while(this._parameterStack.length) {
argsStack.push(this._parameterStack.pop());
}
this.history(method, argsStack);
},
history: function(method, args) {
console.log("%s(%o) called", method, args);
}
});
var iphone = new Device();
iphone.$('setLocation', [10, 100]);
iphone.$('setAspects', [34, 87]);
iphone.$('setLocation', [1324, 344]);