title: Server side onchange event for custom class
body: <p>If I create a custom class in Google Apps Script and assign it to a variable, can I create a server side onchange event that will react when the values change? For example, something like:</p>
  <pre><code>    var Polygon = function(height, width) {
        this.height = height;
        this.width = width;
        this.save = function() { &lt;code to draw the polygon here ...&gt; };
      }
      Polygon.onchange = function() {
        currentPolygon = this.value;
        currentPolygon.draw();
      }
      var myPolygon = new Polygon(10, 12);
      myPolygon.height = 20; // triggers draw
  </code></pre>
  <p>Or, must it be included in a set function? For example:</p>
  <pre><code>    var Polygon = function(height, width) {
        var myHeight = height;
        var myWidth = width;
        this.height = function() { return myHeight; }
        this.width = function() { return myWidth; }
        this.draw = function() { &lt;code to draw the polygon here ...&gt; };
        this.changeHeight = function(value) {
          myHeight = value;
          this.draw();
        }
        this.changeWidth = function(value) {
          myWidth = value;
          this.draw();
        }
      }
      var myPolygon = new Polygon(10, 12);
      myPolygon.changeHeight(20);
  </code></pre>