Skip to content

Commit

Permalink
Move multilink and related methods to Multilink, see phetsims/axon#395
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed May 23, 2022
1 parent b4faccd commit 4dfe228
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
3 changes: 2 additions & 1 deletion js/quadrilateral/model/QuadrilateralShapeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import IReadOnlyProperty from '../../../../axon/js/IReadOnlyProperty.js';
import EnumerationProperty from '../../../../axon/js/EnumerationProperty.js';
import NumberIO from '../../../../tandem/js/types/NumberIO.js';
import IProperty from '../../../../axon/js/IProperty.js';
import Multilink from '../../../../axon/js/Multilink.js';

// A useful type for calculations for the vertex Shapes which define where the Vertex can move depending on
// the positions of the other vertices. Lines are along the bounds of model space and RayIntersections
Expand Down Expand Up @@ -393,7 +394,7 @@ class QuadrilateralShapeModel {
}
} );

Property.multilink( [
Multilink.multilink( [
this.vertexA.positionProperty,
this.vertexB.positionProperty,
this.vertexC.positionProperty,
Expand Down
6 changes: 3 additions & 3 deletions js/quadrilateral/view/CornerGuideNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import Vector2 from '../../../../dot/js/Vector2.js';
import QuadrilateralColors from '../../common/QuadrilateralColors.js';
import BooleanProperty from '../../../../axon/js/BooleanProperty.js';
import QuadrilateralShapeModel from '../model/QuadrilateralShapeModel.js';
import Property from '../../../../axon/js/Property.js';
import NamedQuadrilateral from '../model/NamedQuadrilateral.js';
import Multilink from '../../../../axon/js/Multilink.js';

// constants
// The size of each slice of the angle guide, in radians
Expand Down Expand Up @@ -60,7 +60,7 @@ class CornerGuideNode extends Node {
lineDash: [ 5, 5 ]
} );

Property.multilink( [ vertex1.angleProperty, vertex1.positionProperty ], ( angle, position ) => {
Multilink.multilink( [ vertex1.angleProperty, vertex1.positionProperty ], ( angle, position ) => {
assert && assert( angle !== null, 'angleProperty needs to be defined to add listeners in CornerGuideNode' );
assert && assert( angle! > 0, 'CornerGuideNodes cannot support angles at or less than zero' );
const vertexCenter = vertex1.positionProperty.value;
Expand Down Expand Up @@ -135,7 +135,7 @@ class CornerGuideNode extends Node {

// listeners - This Node is only visible when "Angle Guides" are visible by the user and the angle is NOT a right
// angle. In that case, the RightAngleIndicatorNode will display the angle.
Property.multilink( [ visibleProperty, shapeModel.shapeNameProperty ], ( visible, shapeName ) => {
Multilink.multilink( [ visibleProperty, shapeModel.shapeNameProperty ], ( visible, shapeName ) => {
const currentShape = shapeModel.shapeNameProperty.value;
this.visible = visible && currentShape !== NamedQuadrilateral.SQUARE && currentShape !== NamedQuadrilateral.RECTANGLE;
} );
Expand Down
10 changes: 5 additions & 5 deletions js/quadrilateral/view/ParallelsStaccatoSoundView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author Jesse Greenberg (PhET Interactive Simulations)
*/

import Property from '../../../../axon/js/Property.js';
import Multilink from '../../../../axon/js/Multilink.js';
import LinearFunction from '../../../../dot/js/LinearFunction.js';
import Range from '../../../../dot/js/Range.js';
import optionize from '../../../../phet-core/js/optionize.js';
Expand Down Expand Up @@ -74,15 +74,15 @@ class ParallelsStaccatoSoundView {
};
quadrilateralShapeModel.shapeChangedEmitter.addListener( shapeChangeListener );

const leftRightMultilink = Property.multilink(
const leftRightMultilink = Multilink.multilink(
[ quadrilateralShapeModel.leftSide.tiltProperty, quadrilateralShapeModel.rightSide.tiltProperty ],
( leftTilt, rightTilt ) => {
assert && assert( leftTilt !== Number.POSITIVE_INFINITY && rightTilt !== Number.POSITIVE_INFINITY, 'tilts cannot be infinite in the sound design' );
this.leftRightPopCoefficient = TILT_DIFFERENCE_TO_PITCHED_POP_COEFFICIENT.evaluate( Math.abs( leftTilt - rightTilt ) );
this.leftRightRelativePitch = TILT_DIFFERENCE_TO_PITCH.evaluate( Math.abs( leftTilt - rightTilt ) );
}
);
const topBottomMultilink = Property.multilink(
const topBottomMultilink = Multilink.multilink(
[ quadrilateralShapeModel.topSide.tiltProperty, quadrilateralShapeModel.bottomSide.tiltProperty ],
( topTilt, bottomTilt ) => {
assert && assert( topTilt !== Number.POSITIVE_INFINITY && bottomTilt !== Number.POSITIVE_INFINITY, 'tilts cannot be infinite in the sound design' );
Expand All @@ -101,8 +101,8 @@ class ParallelsStaccatoSoundView {
this.model.quadrilateralShapeModel.shapeChangedEmitter.removeListener( shapeChangeListener );
this.model.resetNotInProgressProperty.unlink( resetListener );

Property.unmultilink( leftRightMultilink );
Property.unmultilink( topBottomMultilink );
Multilink.unmultilink( leftRightMultilink );
Multilink.unmultilink( topBottomMultilink );
};

}
Expand Down
9 changes: 4 additions & 5 deletions js/quadrilateral/view/ParallelsVolumeSoundView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
* @author Jesse Greenberg (PhET Interactive Simulations)
*/

import Property from '../../../../axon/js/Property.js';
import LinearFunction from '../../../../dot/js/LinearFunction.js';
import SoundClipChord from '../../../../tambo/js/sound-generators/SoundClipChord.js';
import soundManager from '../../../../tambo/js/soundManager.js';
import quadrilateral from '../../quadrilateral.js';
import QuadrilateralModel from '../model/QuadrilateralModel.js';
import QuadrilateralSoundOptionsModel, { SuccessSoundFile } from '../model/QuadrilateralSoundOptionsModel.js';
import { UnknownMultilink } from '../../../../axon/js/Multilink.js';
import Multilink, { UnknownMultilink } from '../../../../axon/js/Multilink.js';
import Side from '../model/Side.js';
import WrappedAudioBuffer from '../../../../tambo/js/WrappedAudioBuffer.js';

Expand Down Expand Up @@ -118,15 +117,15 @@ class ParallelsVolumeSoundView {
soundManager.removeSoundGenerator( this.leftRightSideGenerator );
this.leftRightSideGenerator.dispose();

Property.unmultilink( this.leftRightSideMultilink! );
Multilink.unmultilink( this.leftRightSideMultilink! );
}
if ( this.topBottomSideGenerator ) {
assert && assert( this.topBottomSideMultilink, 'The multilink must be established before we dispose of it.' );

soundManager.removeSoundGenerator( this.topBottomSideGenerator );
this.topBottomSideGenerator.dispose();

Property.unmultilink( this.topBottomSideMultilink! );
Multilink.unmultilink( this.topBottomSideMultilink! );
}
}

Expand Down Expand Up @@ -217,7 +216,7 @@ class ParallelsVolumeSoundView {
* difference in tilts of two sides.
*/
public createTiltMultilink( sideA: Side, sideB: Side, applyOutputLevel: ( outputLevel: number ) => void ): UnknownMultilink {
return Property.multilink(
return Multilink.multilink(
[ sideA.tiltProperty, sideB.tiltProperty ],
( leftTilt, rightTilt ) => {

Expand Down
4 changes: 2 additions & 2 deletions js/quadrilateral/view/QuadrilateralNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import CornerGuideNode from './CornerGuideNode.js';
import QuadrilateralColors from '../../common/QuadrilateralColors.js';
import NamedQuadrilateral from '../model/NamedQuadrilateral.js';
import RightAngleIndicatorNode from './RightAngleIndicatorNode.js';
import Property from '../../../../axon/js/Property.js';
import Multilink from '../../../../axon/js/Multilink.js';

// constants
const cornerAString = quadrilateralStrings.a11y.cornerA;
Expand Down Expand Up @@ -170,7 +170,7 @@ class QuadrilateralNode extends Node {

// only if shape identification feedback is enabled, reset the timer so that we change the color for a short
// period when we become a named shape
Property.multilink( [ this.quadrilateralShapeModel.isParallelogramProperty, this.quadrilateralShapeModel.shapeNameProperty ], ( isParallelogram, shapeName ) => {
Multilink.multilink( [ this.quadrilateralShapeModel.isParallelogramProperty, this.quadrilateralShapeModel.shapeNameProperty ], ( isParallelogram, shapeName ) => {
if ( shapeName !== null && quadrilateralModel.shapeIdentificationFeedbackEnabledProperty.value ) {
this.remainingTimeForShapeChangeFill = SHAPE_FILL_TIME;
}
Expand Down
4 changes: 2 additions & 2 deletions js/quadrilateral/view/SideLengthAreaNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { Shape } from '../../../../kite/js/imports.js';
import ModelViewTransform2 from '../../../../phetcommon/js/view/ModelViewTransform2.js';
import QuadrilateralShapeModel from '../model/QuadrilateralShapeModel.js';
import QuadrilateralUtils from '../../common/QuadrilateralUtils.js';
import Property from '../../../../axon/js/Property.js';
import optionize from '../../../../phet-core/js/optionize.js';
import Multilink from '../../../../axon/js/Multilink.js';

type SideLengthAreaNodeSelfOptions = {
drawRotation?: number;
Expand All @@ -42,7 +42,7 @@ class SideLengthAreaNode extends Node {

this.children = [ vertex1Path, vertex2Path ];

Property.multilink( [
Multilink.multilink( [
shapeModel.lengthsEqualToSavedProperty,
dragSide.isPressedProperty,
dragSide.vertex1.isPressedProperty,
Expand Down
4 changes: 2 additions & 2 deletions js/quadrilateral/view/SideNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @author Jesse Greenberg (PhET Interactive Simulations)
*/

import Property from '../../../../axon/js/Property.js';
import merge from '../../../../phet-core/js/merge.js';
import { DragListener, KeyboardDragListener, Line as LineNode, Path, SceneryEvent, Voicing } from '../../../../scenery/js/imports.js';
import Tandem from '../../../../tandem/js/Tandem.js';
Expand All @@ -23,6 +22,7 @@ import { Line, Shape } from '../../../../kite/js/imports.js';
import QuadrilateralColors from '../../common/QuadrilateralColors.js';
import vibrationManager from '../../../../tappi/js/vibrationManager.js';
import SideDescriber from './SideDescriber.js';
import Multilink from '../../../../axon/js/Multilink.js';

// The dilation around side shapes when drawing the focus highlight.
const FOCUS_HIGHLIGHT_DILATION = 15;
Expand Down Expand Up @@ -85,7 +85,7 @@ class SideNode extends Voicing( Path, 1 ) {
const lineNode = new LineNode( 0, 0, 0, 0 );

// listeners
Property.multilink( [ side.vertex1.positionProperty, side.vertex2.positionProperty ], ( vertex1Position, vertex2Position ) => {
Multilink.multilink( [ side.vertex1.positionProperty, side.vertex2.positionProperty ], ( vertex1Position, vertex2Position ) => {

// create a single line that will then be divided into segments
const fullLine = new Line( vertex1Position, vertex2Position );
Expand Down

0 comments on commit 4dfe228

Please sign in to comment.