Missing dependency for DerivedProperty
Closed this issue · 2 comments
Related to phetsims/axon#441 ...
In d2f0050, @samreid added accessNonDependencies: true
to temporarily silence missing a missing dependencies for a DerivedProperty. It should be addressed.
In Scale.ts:
this.quantityProperty = new DerivedProperty(
[ this.numberOfBagsProperty, this.numberOfItemsProperty ],
( numberOfBags, numberOfItems ) => {
if ( this.quantityUpdateEnabled ) {
return ( numberOfBags * options.quantityPerBag ) + numberOfItems;
}
else {
return this.quantityProperty.value;
}
},
The missing dependency is itself, this.quantityProperty
. We're still negotiating whether that's a necessary dependency, see phetsims/axon#441 (comment). So on hold until that's decided.
In phetsims/axon#441 (comment), @samreid and I said:
We decided that this complicates DerivedProperty unnecessarily. And self-reference should be something that is rarely done, possibly even to be avoided. In cases where it is necessary, the developer should opt out ...
So I'll continue to opt out using accessNonDependencies: true
in this sim. And I'll close this issue.