lundi 3 décembre 2018

Determine which bindings caused computed property to update

Say I have a controller with a computed dependency tree like

a
  b
    c
      d
  e
    c
  f
    c

  • updating a should re-compute all properties
  • the bindings for c are b, e, f

How can I log out which binding caused a computed property to update? I want to do something like

const ctrl = Ember.Controller.extend({
  a: null,
  b: Ember.computed('a', foo),
  c: Ember.computed('b, e, f', function () {
    // did b, e, or f trigger this?
  }),
  d: Ember.computed('c', fizz),
  e: Ember.computed('a', buzz),
  f: Ember.computed('a', blah)
});

ctrl.set('a', 'foobar');
// => should see if b, e, or f was triggered last




Aucun commentaire:

Enregistrer un commentaire