mardi 26 mai 2015

Confusion About Observers and Unconsumed Computed Properties

I am having trouble understanding the statement below and have read it multiple times unfortunately:

If you never get a computed property, its observers will not fire even if its dependent keys change. You can think of the value changing from one unknown value to another.

This doesn't usually affect application code because computed properties are almost always observed at the same time as they are fetched. For example, you get the value of a computed property, put it in DOM (or draw it with D3), and then observe it so you can update the DOM once the property changes.

This is part of

http://ift.tt/1dveqUd

An example of an observer is:

Person = Ember.Object.extend({
  init: function() {
    this.set('salutation', "Mr/Ms");
  },

  salutationDidChange: function() {
    // some side effect of salutation changing
  }.observes('salutation').on('init')
});

Does this mean that if I don't call

person.get('salutationDidChange') it will be considered an unconsumed computed property, and it will not execute even if salutation changes?




Aucun commentaire:

Enregistrer un commentaire