Skip to content

Commit

Permalink
convert {null|*} from isValidValue function to valueType: [null, *], p…
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Jul 19, 2019
1 parent cf0a526 commit 5271f02
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion js/common/model/GQModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ define( require => {

// @public {Property.<Quadratic|null>} the saved quadratic, null if nothing is saved
this.savedQuadraticProperty = new Property( null, {
isValidValue: value => ( value instanceof Quadratic || value === null ),
valueType: [ Quadratic, null ],
tandem: tandem.createTandem( 'savedQuadraticProperty' ),
phetioDocumentation: 'the saved quadratic, null if there is no saved quadratic',
phetioType: PropertyIO( NullableIO( QuadraticIO ) )
Expand Down
2 changes: 1 addition & 1 deletion js/common/model/PointTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ define( require => {
return null;
}
}, {
isValidValue: value => ( value instanceof Quadratic || value === null ),
valueType: [ Quadratic, null ],
tandem: options.tandem.createTandem( 'onQuadraticProperty' ),
phetioDocumentation: 'the quadratic that this point tool is on, null if not on a quadratic',
phetioType: DerivedPropertyIO( NullableIO( QuadraticIO ) )
Expand Down
2 changes: 1 addition & 1 deletion js/common/view/PointToolNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ define( require => {

const coordinatesProperty = new DerivedProperty( [ pointTool.locationProperty ],
location => ( graph.contains( location ) ? location : null ), {
isValidValue: value => ( value instanceof Vector2 || value === null )
valueType: [ Vector2, null ]
} );

// coordinates display
Expand Down
2 changes: 1 addition & 1 deletion js/common/view/VertexManipulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ define( require => {
// coordinates correspond to the quadratic's vertex (if it has one)
const coordinatesProperty = new DerivedProperty( [ quadraticProperty ],
quadratic => ( quadratic.vertex ? quadratic.vertex : null ), {
isValidValue: value => ( value instanceof Vector2 || value === null ),
valueType: [ Vector2, null ],
tandem: options.tandem.createTandem( 'coordinatesProperty' ),
phetioDocumentation: 'coordinates displayed by on vertex manipulator, null means no vertex',
phetioType: DerivedPropertyIO( NullableIO( Vector2IO ) )
Expand Down
8 changes: 4 additions & 4 deletions js/standardform/view/RootsNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ define( require => {

// options common to both Property instances
const coordinatesPropertyOptions = {
isValidValue: value => ( value instanceof Vector2 || value === null ),
valueType: [ Vector2, null ],
phetioType: DerivedPropertyIO( NullableIO( Vector2IO ) )
};

// coordinates corresponding to the quadratic's left or single root (if it has roots)
const leftCoordinatesProperty = new DerivedProperty( [ quadraticProperty ],
quadratic => ( quadratic.roots && quadratic.roots.length > 0 ) ? quadratic.roots[ 0 ] : null,
quadratic => ( quadratic.roots && quadratic.roots.length > 0 ) ? quadratic.roots[ 0 ] : null,
_.extend( {}, coordinatesPropertyOptions, {
tandem: options.tandem.createTandem( 'leftCoordinatesProperty' ),
phetioDocumentation: 'coordinates displayed on the left (first) root, ' +
Expand All @@ -62,7 +62,7 @@ define( require => {

// coordinates corresponding to the quadratic's right root, if it has 2 roots
const rightCoordinatesProperty = new DerivedProperty( [ quadraticProperty ],
quadratic => ( quadratic.roots && quadratic.roots.length === 2 ) ? quadratic.roots[ 1 ] : null,
quadratic => ( quadratic.roots && quadratic.roots.length === 2 ) ? quadratic.roots[ 1 ] : null,
_.extend( {}, coordinatesPropertyOptions, {
tandem: options.tandem.createTandem( 'rightCoordinatesProperty' ),
phetioDocumentation: 'coordinates displayed on the right (second) root, ' +
Expand All @@ -78,7 +78,7 @@ define( require => {
x: modelViewTransform.modelToViewX( graph.xRange.getCenter() ),
y: modelViewTransform.modelToViewY( graph.yRange.getCenter() )
};

// left root
const leftRootNode = new PointNode( leftCoordinatesProperty, coordinatesVisibleProperty,
_.extend( {}, pointNodeOptions, {
Expand Down
2 changes: 1 addition & 1 deletion js/standardform/view/VertexNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ define( require => {
// coordinates correspond to the quadratic's vertex (if it has one)
const coordinatesProperty = new DerivedProperty( [ quadraticProperty ],
quadratic => ( quadratic.vertex ? quadratic.vertex : null ), {
isValidValue: value => ( value instanceof Vector2 || value === null ),
valueType: [ Vector2, null ],
tandem: options.tandem.createTandem( 'coordinatesProperty' ),
phetioDocumentation: 'coordinates displayed on the vertex point, null means no vertex',
phetioType: DerivedPropertyIO( NullableIO( Vector2IO ) )
Expand Down

0 comments on commit 5271f02

Please sign in to comment.