Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing dependency for DerivedProperty #223

Closed
pixelzoom opened this issue Nov 14, 2023 · 2 comments
Closed

Missing dependency for DerivedProperty #223

pixelzoom opened this issue Nov 14, 2023 · 2 comments
Assignees

Comments

@pixelzoom
Copy link
Contributor

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.

@pixelzoom
Copy link
Contributor Author

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.

@pixelzoom
Copy link
Contributor Author

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.

pixelzoom added a commit that referenced this issue Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant