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

Why are LinkedElements phetioReadOnly: true? #272

Open
samreid opened this issue Sep 19, 2022 · 2 comments
Open

Why are LinkedElements phetioReadOnly: true? #272

samreid opened this issue Sep 19, 2022 · 2 comments

Comments

@samreid
Copy link
Member

samreid commented Sep 19, 2022

From phetsims/joist#744

    // This seems buggy since LinkedElement has no setter/mutation methods
    // So shouldn't it inherit like everything else?
class LinkedElement extends PhetioObject {
  public readonly element: LinkableElement;

  public constructor( coreElement: LinkableElement, providedOptions?: LinkedElementOptions ) {
    assert && assert( !!coreElement, 'coreElement should be defined' );

    const options = optionize<LinkedElementOptions, EmptySelfOptions, PhetioObjectOptions>()( {
      phetioType: LinkedElementIO,
      phetioState: false
    }, providedOptions );

    // References cannot be changed by PhET-iO
    assert && assert( !options.hasOwnProperty( 'phetioReadOnly' ), 'phetioReadOnly set by LinkedElement' );
    options.phetioReadOnly = true;
@zepumph
Copy link
Member

zepumph commented Sep 19, 2022

I thought it was buggy when I thought we were going to be building out support for calling methods on linked elements and forwarding those calls to the core elements, but the "read only" part is inherent to LinkedElementIO, and I can see it making sense. What do you prefer?

@samreid
Copy link
Member Author

samreid commented Sep 19, 2022

I had expected to see it forward values like it does for phetioFeatured.

options.phetioFeatured = coreElement.phetioFeatured;

But I'm sure I can get used to it either way--not sure which is best.

@samreid samreid removed their assignment Sep 27, 2022
@zepumph zepumph removed their assignment Mar 3, 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

2 participants