I would like to create a component that takes a list of property names and then dynamically builds a computed property which has each value from the list as a dependent key.
{{buttons-list-component
title="Status"
propertyNames="active, expired, pending"
toggleProperty="toggleProperty"
active=active
expired=expired
pending=pending
}}
For the above example, I would like to to take the string passed as propertyNames
, split it into an array and then have the optionsObject
computed property watch each value in the array as if it was passed explicitly.
propertiesArray: function() {
return this.get('propertyNames').split(", ");
}.property('propertyNames'),
When the property active
is updated, the code below will not run, because the propertyNames
has not been updated, and therefore propertiesArray
has not changed.
optionsObject: function() {
console.log("foo") // Does not run.
}.property('propertiesArray.@each'),
Is there a way to build the computed property, so that it would work in the same way as the code below, but without explicitly passing the string value of each property that optionsObject
is dependant on?
optionsObject: function() {
console.log("bar") // Does run.
}.property('active', 'expired', 'pending''),