phetsims / unit-rates

"Unit Rates" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
0 stars 2 forks source link

Missing dependency for DerivedProperty #223

Closed pixelzoom closed 8 months ago

pixelzoom commented 9 months ago

Related to https://github.com/phetsims/axon/issues/441 ...

In https://github.com/phetsims/unit-rates/commit/d2f0050f10d551c9258baace56fa8808a04ab7b5, @samreid added accessNonDependencies: true to temporarily silence missing a missing dependencies for a DerivedProperty. It should be addressed.

pixelzoom commented 9 months ago

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 https://github.com/phetsims/axon/issues/441#issuecomment-1810592906. So on hold until that's decided.

pixelzoom commented 8 months ago

In https://github.com/phetsims/axon/issues/441#issuecomment-1861331455, @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.