nicklandgrebe / active-resource.js

ActiveResource.js - API resource relational mapping in JavaScript
https://active-resource.js.org
MIT License
133 stars 20 forks source link

Change tracking broken in 9.4 #21

Closed greywolvez closed 7 years ago

greywolvez commented 7 years ago

The following line prevents patching from detecting the correct changes.

https://github.com/nicklandgrebe/activeresource.js/blob/master/dist/active-resource.js#L1139

The ! should be deleted for the field to be generated correctly,

greywolvez commented 7 years ago

This happens when I tried to build a fresh object from a cached copy. The copy has fields already defined. This may not be the intended use at this time.

greywolvez commented 7 years ago

I am new to this and I can see that the in the changedfields() function you are checking this.klass.fields() but I can not figure out how to actually assign the fields. Do you have a working example of what that might look like?

nicklandgrebe commented 7 years ago

Hi,

You can define specific properties you want to track like so:

class Resource extends MyLibrary.Base
  # Track changes to instance.property1 and instance.property2
  this.attributes('property1', 'property2')

  # Relationships automatically are tracked
  this.hasMany('orders')

I've been meaning to document this, 0.9.4 was just released