-
Notifications
You must be signed in to change notification settings - Fork 12
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
Remove NodeIO PhET-iO sub Properties #1046
Comments
@jonathanolson, @samreid, @chrisklus, and I all worked on passing in visibleProperty to Node, and supporting it as an "instrumented sub Property" in the correct cases. This involved adding There were a couple of loose ends that we want to try to fix before allowing opening up the visibleProperty API for mass consumption:
|
…ies (with associated phet-io support). See #1046
… is unchanged, we'll want read-only in the future, see phetsims/scenery#1046
|
Fixed in the commit above. When creating the default |
I see these points to move forward here:
The second bullet feels like something we could determine without knowing the outcome of the first. |
I think that the visibilityProperty support code added above also needs a review here. I will do that as part of my review in #490. Some TODOs will be linked here though. |
|
After reviewing in #490, I would say that this issue is blocking publication until we feel confident that |
Above is a large refactor of how setVisibleProperty works. It makes the linked element function (updateLinkedElementForVisibleProperty) much more graceful, and also simplifies Node.initializePhetioObject(). @samreid, since you left, the main change was that multiple Nodes in tests could not be disposed because they were created while expecting an assertion (via Next we need to work on Index: js/nodes/Node.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- js/nodes/Node.js (revision 3c13c3f7348a650fc8488e3dc2b2d816eaeeac44)
+++ js/nodes/Node.js (date 1602284248745)
@@ -5291,7 +5291,7 @@
phetioReadOnly: this.phetioReadOnly, // pick the baseline value from the parent Node's baseline
tandem: this.tandem.createTandem( 'visibleProperty' ),
phetioDocumentation: 'Controls whether the Node will be visible (and interactive), see the NodeIO documentation for more details.'
- }, this.phetioComponentOptions, this.phetioComponentOptions.visibleProperty, config.visiblePropertyOptions ) );
+ }, config.visiblePropertyOptions ) );
this.setVisibleProperty( this.ownedPhetioVisibleProperty );
}
@samreid does this belong in a separate issue? Please review the above commits. |
This unit test is failing: window.assert && assert.throws( () => {
instrumented3.mutate( { visibleProperty: otherInstrumentedVisibleProperty } );
}, 'cannot swap out one instrumented for another' ); I traced this and saw that when the LinkedElement is disposed, This has been a tricky case because Tandem.launched takes a different value based on what other tests have run previously. |
…alidation can run, see phetsims/scenery#1046
The commits look great, I don't have any recommendations aside from the commits I made in NodeTests.js. I'm not confident to proceed on UPDATE: Or is the plan to replace cases like: options = merge( {
// phet-io
tandem: Tandem.REQUIRED,
phetioComponentOptions: {
// model controls visibility
visibleProperty: {
phetioReadOnly: true,
phetioDocumentation: 'visibility is controlled by the model'
}
}
}, options ); with options = merge( {
// phet-io
tandem: Tandem.REQUIRED,
visiblePropertyOptions:{
phetioReadOnly: true,
phetioDocumentation: 'visibility is controlled by the model'
}
}, options ); ? |
@samreid and I thought about a patch like this, but I think it is too constraining. For example if Panel wants its default visibleProperty to act a certain way, but we also support passing in a usage-specific visibleProperty. I think we should be tolerant of that: Index: js/nodes/Node.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- js/nodes/Node.js (revision e4673533f38500674f39a1a2d65bb78e306fa65a)
+++ js/nodes/Node.js (date 1602697822420)
@@ -5297,6 +5297,10 @@
}
else {
+
+ // TODO: I'm worried this will be too constraining, what if a default button options want to add metadata https://github.com/phetsims/scenery/issues/1046
+ assert && assert( !config.visiblePropertyOptions , 'Cannot specify visibleProperty and visiblePropertyOptions for default instrumented Node.visibleProperty.' );
+
// Since we are just now instrumented, and linked elements can't be added to linked Elements until the PhetioObject
// is instrumented, we need to retroactively link to whatever forwardingProperty may have been added before.
this.updateLinkedElementForVisibleProperty( null, this.visibleProperty.forwardingProperty, false ); UPDATE: Here is an example of the EnabledComponent having strong assertions like this, and needing extra logic in Slider to get around providing both. I'm not sure this is the best way to do things, though it makes the mixin quite clear: |
RE: #1046 (comment), @samreid and I updated documentation, and are ok with not asserting. |
Now that we have Properties in Node (see #490), (work stemming from discussion in https://github.com/phetsims/phet-io/issues/1642), we can likely replace the complicated pattern of having NodeIO defined PhET-iO instrumented Properties for instrumented Nodes.
Some of the specification that apply to this issue were outlined in #490 (comment) at last developer meeting:
These are all good questions for this issue when @jonathanolson, @samreid, @chrisklus and I meet today to work on this issue.
The text was updated successfully, but these errors were encountered: