lundi 20 mai 2019

How can I make an Ember computed property depend on all descendent properties of a variable?

I'm trying to create a computed property that I want to be reevaluated whenever any value in a deeply nested object changes. I understand that myObj.[] can be used to reevaluate computed properties whenever any object in an array changes, but I want this to be recursive.

eg I have

// should recalculate whenever myObj.x.y.z changes, or when myObj.a.b.c changes
computed('myObj', function() {
  // ...
})

I don't know in advance exactly how the object is structured, and it may be arbitrarily deep.

Neither computed('myObj.[]', ...) nor computed('myObj.@each', ...) seem to work for this.

Any ideas how to do this?




Aucun commentaire:

Enregistrer un commentaire