Skip to content

Commit

Permalink
Replace phetioType with phetioValueType, see phetsims/axon#260
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Aug 10, 2022
1 parent 6cdc7e6 commit 3396084
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
16 changes: 8 additions & 8 deletions js/common/model/Body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,23 +236,23 @@ export default class Body extends PhetioObject {
// rewindable properties - body states can be rewound, and these properties can have saved states to support this

this.positionProperty = new RewindableProperty<Vector2>( changeRewindValueProperty, new Vector2( bodyConfiguration.x, bodyConfiguration.y ), {
phetioType: RewindableProperty.RewindablePropertyIO( Vector2.Vector2IO ),
phetioValueType: Vector2.Vector2IO,
tandem: tandem.createTandem( 'positionProperty' ),
units: 'm',
phetioHighFrequency: true,
phetioDocumentation: 'The position of the body'
} );

this.velocityProperty = new RewindableProperty( changeRewindValueProperty, new Vector2( bodyConfiguration.vx, bodyConfiguration.vy ), {
phetioType: RewindableProperty.RewindablePropertyIO( Vector2.Vector2IO ),
phetioValueType: Vector2.Vector2IO,
tandem: tandem.createTandem( 'velocityProperty' ),
units: 'm/s',
phetioHighFrequency: true,
phetioDocumentation: 'The absolute speed and direction of motion of the body'
} );

this.speedProperty = new DerivedProperty( [ this.velocityProperty ], velocity => velocity.magnitude, {
phetioType: DerivedProperty.DerivedPropertyIO( NumberIO ),
phetioValueType: NumberIO,
tandem: tandem.createTandem( 'speedProperty' ),
units: 'm/s',
phetioHighFrequency: true,
Expand All @@ -261,7 +261,7 @@ export default class Body extends PhetioObject {

this.forceProperty = new RewindableProperty( changeRewindValueProperty, new Vector2( 0, 0 ), {
phetioDocumentation: 'The net force of gravity exerted on this body by other bodies',
phetioType: RewindableProperty.RewindablePropertyIO( Vector2.Vector2IO ),
phetioValueType: Vector2.Vector2IO,
tandem: tandem.createTandem( 'forceProperty' ),
phetioHighFrequency: true,
units: 'N',
Expand All @@ -270,29 +270,29 @@ export default class Body extends PhetioObject {

this.forceMagnitudeProperty = new DerivedProperty( [ this.forceProperty ], force => force.magnitude, {
phetioDocumentation: 'The magnitude of the net force on this body by other bodies',
phetioType: DerivedProperty.DerivedPropertyIO( NumberIO ),
phetioValueType: NumberIO,
tandem: tandem.createTandem( 'forceMagnitudeProperty' ),
phetioHighFrequency: true,
units: 'N'
} );

this.massProperty = new RewindableProperty( changeRewindValueProperty, bodyConfiguration.mass, {
tandem: tandem.createTandem( 'massProperty' ),
phetioType: RewindableProperty.RewindablePropertyIO( NumberIO ),
phetioValueType: NumberIO,
units: 'kg',
phetioDocumentation: 'The mass of the body'
} );

this.isCollidedProperty = new RewindableProperty<boolean>( changeRewindValueProperty, false, {
tandem: tandem.createTandem( 'isCollidedProperty' ),
phetioType: RewindableProperty.RewindablePropertyIO( BooleanIO ),
phetioValueType: BooleanIO,
phetioReadOnly: true,
phetioDocumentation: 'True if the body has collided with another body'
} );

this.rotationProperty = new RewindableProperty( changeRewindValueProperty, 0, {
tandem: tandem.createTandem( 'rotationProperty' ),
phetioType: RewindableProperty.RewindablePropertyIO( NumberIO ),
phetioValueType: NumberIO,
units: 'radians',
phetioHighFrequency: true,
phetioDocumentation: 'The rotation of the body about its own origin'
Expand Down
2 changes: 1 addition & 1 deletion js/common/model/GravityAndOrbitsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class GravityAndOrbitsModel {
this.sceneProperty = new Property( this.sceneList.scenes[ 0 ], {
tandem: tandem.createTandem( 'sceneProperty' ),
validValues: this.sceneList.scenes,
phetioType: Property.PropertyIO( ReferenceIO( IOType.ObjectIO ) )
phetioValueType: ReferenceIO( IOType.ObjectIO )
} );
}

Expand Down
2 changes: 1 addition & 1 deletion js/common/model/Pair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Pair {
this.body2.positionProperty
], ( body1Position, body2Position ) => body2Position.distance( body1Position ), {
tandem: tandem.createTandem( 'distanceProperty' ),
phetioType: DerivedProperty.DerivedPropertyIO( NumberIO ),
phetioValueType: NumberIO,
phetioHighFrequency: true,
units: 'm'
} );
Expand Down
14 changes: 8 additions & 6 deletions js/common/model/RewindableProperty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@
*/

import BooleanProperty from '../../../../axon/js/BooleanProperty.js';
import Property from '../../../../axon/js/Property.js';
import Property, { PropertyOptions } from '../../../../axon/js/Property.js';
import gravityAndOrbits from '../../gravityAndOrbits.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import IOType from '../../../../tandem/js/types/IOType.js';
import { PhetioObjectOptions } from '../../../../tandem/js/PhetioObject.js';
import TReadOnlyProperty from '../../../../axon/js/TReadOnlyProperty.js';
import { combineOptions } from '../../../../phet-core/js/optionize.js';
import StrictOmit from '../../../../phet-core/js/types/StrictOmit.js';

type RewindablePropertyOptions = {
type RewindablePropertyOptions<T> = {
units?: string;
tandem: Tandem;
} & PhetioObjectOptions;
} & StrictOmit<PhetioObjectOptions, 'phetioType'> & Pick<PropertyOptions<T>, 'phetioOuterType' | 'phetioValueType'>;

class RewindableProperty<T> extends Property<T> {
private rewindValue: T;
Expand All @@ -35,10 +36,11 @@ class RewindableProperty<T> extends Property<T> {
* @param value
* @param [providedOptions]
*/
public constructor( changeRewindValueProperty: TReadOnlyProperty<boolean>, value: T, providedOptions?: RewindablePropertyOptions ) {
public constructor( changeRewindValueProperty: TReadOnlyProperty<boolean>, value: T, providedOptions?: RewindablePropertyOptions<T> ) {

const options = combineOptions<RewindablePropertyOptions>( {
tandem: Tandem.OPTIONAL
const options = combineOptions<RewindablePropertyOptions<T>>( {
tandem: Tandem.OPTIONAL,
phetioOuterType: RewindableProperty.RewindablePropertyIO
}, providedOptions );

super( value, options );
Expand Down

0 comments on commit 3396084

Please sign in to comment.