How to override an attribute in Ember Data 1.0.0?

Is there a way to override the attribute installer in Ember Data 1.0.0? I would like to clear the data before any events are fired or updated properties are updated.

I am currently using the following method, but I do not like it, because I should always remember to use dirtyPositionwhen setting a new value:

SampleApp.Line = DS.Model.extend({

  position: DS.attr("number"),

  dirtyPosition: function(key, value) {
    this.set("position", Math.max(0, value));
  }

});

It would be much better if I somehow redefined the property position... But I cannot find a way to do this.

+4
source share
1 answer

I would try redefining Ember.Object#set; The source is here .

0

Source: https://habr.com/ru/post/1531402/


All Articles