Skip to content

Poor man's object.observe to get object diffs with Sweet.js

Notifications You must be signed in to change notification settings

btford/sweet-observe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Sweet Observe

Using Sweet.js macros to get object property change lists for methods inside of a prototype.

Compile

Must be compiled with SweetJS. Install via npm:

npm install -g sweet.js

Run make:

make

Run

node app

Syntax

Turns this:

Model.prototype.test = function () {
  this_(x.y.z = 20);
}

into this:

Model.prototype.test = function () {
    this._changed.x = this._changed.x || {};
    this._changed.x.y = this._changed.x.y || {};
    this._changed.x.y.z = 20;
    this.x.y.z = 20;
};

About

Poor man's object.observe to get object diffs with Sweet.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published