Skip to content

Commit

Permalink
Use ReferenceIO, see phetsims/tandem#215
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Nov 24, 2020
1 parent 060c75c commit e5aad97
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 38 deletions.
12 changes: 2 additions & 10 deletions js/common/model/Body.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import IOType from '../../../../tandem/js/types/IOType.js';
import ReferenceIO from '../../../../tandem/js/types/ReferenceIO.js';
import massesAndSprings from '../../massesAndSprings.js';
import massesAndSpringsStrings from '../../massesAndSpringsStrings.js';
import MassesAndSpringsConstants from '../MassesAndSpringsConstants.js';
Expand Down Expand Up @@ -46,16 +47,7 @@ Body.BODIES = [ Body.MOON, Body.EARTH, Body.JUPITER, Body.PLANET_X, Body.CUSTOM
Body.BodyIO = new IOType( 'BodyIO', {
valueType: Body,
documentation: 'Planet which determines the force of gravity.',

// TODO: https://github.com/phetsims/tandem/issues/215 use ReferenceIO or equivalent
toStateObject: body => {
if ( body === null ) {
return null;
}
return {
body: body
};
}
supertype: ReferenceIO( IOType.ObjectIO )
} );

export default Body;
17 changes: 0 additions & 17 deletions js/common/model/Mass.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import Range from '../../../../dot/js/Range.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import Vector2Property from '../../../../dot/js/Vector2Property.js';
import merge from '../../../../phet-core/js/merge.js';
import IOType from '../../../../tandem/js/types/IOType.js';
import NullableIO from '../../../../tandem/js/types/NullableIO.js';
import Easing from '../../../../twixt/js/Easing.js';
import massesAndSprings from '../../massesAndSprings.js';
Expand Down Expand Up @@ -367,20 +366,4 @@ class Mass {

massesAndSprings.register( 'Mass', Mass );

// TODO: This is currently unused
Mass.MassIO = new IOType( 'MassIO', {
valueType: Mass,
documentation: 'Model element for one of the masses',
// TODO: https://github.com/phetsims/tandem/issues/215 use ReferenceIO or equivalent
toStateObject: mass => {
if ( mass === null ) {
return null;
}
return {
mass: mass.mass,
color: mass.color
};
}
} );

export default Mass;
13 changes: 2 additions & 11 deletions js/common/model/Spring.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Vector2 from '../../../../dot/js/Vector2.js';
import Vector2Property from '../../../../dot/js/Vector2Property.js';
import IOType from '../../../../tandem/js/types/IOType.js';
import NumberIO from '../../../../tandem/js/types/NumberIO.js';
import ReferenceIO from '../../../../tandem/js/types/ReferenceIO.js';
import massesAndSprings from '../../massesAndSprings.js';
import MassesAndSpringsConstants from '../MassesAndSpringsConstants.js';

Expand Down Expand Up @@ -613,17 +614,7 @@ massesAndSprings.register( 'Spring', Spring );
Spring.SpringIO = new IOType( 'SpringIO', {
valueType: Spring,
documentation: 'Hangs from the ceiling and applies a force to any attached BodyIO',

// TODO: https://github.com/phetsims/tandem/issues/215 use ReferenceIO or equivalent
toStateObject: spring => {
if ( spring === null ) {
return null;
}
return {
position: spring.positionProperty.get(),
id: spring.tandem.phetioID
};
}
supertype: ReferenceIO( IOType.ObjectIO )
} );

export default Spring;

0 comments on commit e5aad97

Please sign in to comment.