Closed samreid closed 4 years ago
phetioCommandProcessor invokes the method like so:
const result = methodSignature.implementation.apply( wrapper, args );
I asked @zepumph which is better between:
setValue: {
returnType: VoidIO,
parameterTypes: [ parameterType ],
implementation: function( value ) {
this.set( value );
},
documentation: 'Sets the value of the Property. If the value differs from the previous value, listeners are ' +
'notified with the new value.',
invocableForReadOnlyElements: false
},
and
setValue: {
returnType: VoidIO,
parameterTypes: [ parameterType ],
implementation: function( property,value ) {
property.set( value );
},
documentation: 'Sets the value of the Property. If the value differs from the previous value, listeners are ' +
'notified with the new value.',
invocableForReadOnlyElements: false
},
And he recommended using this
.
I mentioned we could create a backward compatible patch like so:
const result = methodSignature.implementation.apply( { phetioObject: targetObject }, args );
But using this may be clearest. I'll make that change as part of this changeset.
I have many things working nicely, and the wrapper type eliminated completely.
However, phet-io unit tests are failing because of the NodeIO properties.
On hold until https://github.com/phetsims/scenery/issues/1046 and possibly https://github.com/phetsims/scenery/issues/1047 are complete.
UPDATE FROM MK: and https://github.com/phetsims/scenery/issues/1082
One aspect of the patch was not blocked by the issues mentioned in the prior comment, so I decided to move forward with that change in order to (a) make that improvement and (b) prepare a more succinct patch since we may not return to this issue while it is fresh in our minds or before there is more churn in these files.
Here is the reduced patch after the above commits:
I implemented a pattern for this as part of https://github.com/phetsims/tandem/issues/211. @zepumph can you review this part in isolation? See IOType.createWrapper
and its usages.
This makes a lot of sense. Thanks for taking this on. I'll stay assigned until those issues blocking issues are dealt with.
The title of this issue has been completed, since IOType is not a constructor for wrappers. However, now we would like to eliminate the wrapper completely, so I'll retitle the issue.
Implemented in the commits, and I moved https://github.com/phetsims/phet-io/issues/1712 to a side issue that I may need help on. @zepumph can you please review?
Looks really good. I cleaned up "wrapper" terminology because we no longer think of IO Types as "wrappers" to the core type, and it is over-loaded with the other side of the cross-frame communication (wrapper side).
Closing, please reopen if there is anything else for you.
From https://github.com/phetsims/tandem/issues/188#issuecomment-689779651
PhetioObject calls:
However, it is unimportant that the IO Type constructor be used to create the wrapper. The wrapper just consists of a
phetioID
andphetioObject
. We should eliminate this unnecessary use of ObjectIO's constructor.