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 688fd95 commit b4fc53a
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 21 deletions.
3 changes: 2 additions & 1 deletion js/MeasuringTapeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

import DerivedProperty from '../../axon/js/DerivedProperty.js';
import Multilink from '../../axon/js/Multilink.js';
import Property from '../../axon/js/Property.js';
import Bounds2 from '../../dot/js/Bounds2.js';
import Utils from '../../dot/js/Utils.js';
Expand Down Expand Up @@ -301,7 +302,7 @@ class MeasuringTapeNode extends Node {

// link the positions of base and tip to the measuring tape to the scenery update function.
// Must be disposed.
const multilink = Property.multilink(
const multilink = Multilink.multilink(
[ this.measuredDistanceProperty, unitsProperty, this.modelViewTransformProperty, this.tipPositionProperty, this.basePositionProperty ], (
measuredDistance, units, modelViewTransform, tipPosition, basePosition ) => {

Expand Down
7 changes: 4 additions & 3 deletions js/NumberPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import DerivedProperty from '../../axon/js/DerivedProperty.js';
import Multilink from '../../axon/js/Multilink.js';
import EnumerationDeprecatedProperty from '../../axon/js/EnumerationDeprecatedProperty.js';
import NumberProperty from '../../axon/js/NumberProperty.js';
import Property from '../../axon/js/Property.js';
Expand Down Expand Up @@ -401,12 +402,12 @@ class NumberPicker extends AccessibleNumberSpinner( Node, 0 ) {
valueProperty.link( valueObserver ); // must be unlinked in dispose

// @private update colors for increment components
Property.multilink( [ incrementButtonStateProperty, incrementEnabledProperty ], ( state, enabled ) => {
Multilink.multilink( [ incrementButtonStateProperty, incrementEnabledProperty ], ( state, enabled ) => {
updateColors( state, enabled, incrementBackgroundNode, this.incrementArrow, backgroundColors, arrowColors );
} );

// @private update colors for decrement components
Property.multilink( [ decrementButtonStateProperty, decrementEnabledProperty ], ( state, enabled ) => {
Multilink.multilink( [ decrementButtonStateProperty, decrementEnabledProperty ], ( state, enabled ) => {
updateColors( state, enabled, decrementBackgroundNode, this.decrementArrow, backgroundColors, arrowColors );
} );

Expand Down Expand Up @@ -532,7 +533,7 @@ class NumberPickerInputListener extends FireListener {
*/
constructor( buttonStateProperty, options ) {
super( options );
Property.multilink(
Multilink.multilink(
[ this.isOverProperty, this.isPressedProperty ],
( isOver, isPressed ) => {
buttonStateProperty.set(
Expand Down
8 changes: 4 additions & 4 deletions js/ParametricSpringNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

import NumberProperty from '../../axon/js/NumberProperty.js';
import Property from '../../axon/js/Property.js';
import Multilink from '../../axon/js/Multilink.js';
import Range from '../../dot/js/Range.js';
import Vector2 from '../../dot/js/Vector2.js';
import { Shape } from '../../kite/js/imports.js';
Expand Down Expand Up @@ -145,7 +145,7 @@ class ParametricSpringNode extends Node {

// Changes to these properties require new points (Vector2) and Shapes, because they change
// the number of points and/or how the points are allocated to frontShape and backShape.
Property.multilink( [
Multilink.multilink( [
this.loopsProperty, this.pointsPerLoopProperty,
this.aspectRatioProperty, this.phaseProperty, this.deltaPhaseProperty
],
Expand Down Expand Up @@ -232,7 +232,7 @@ class ParametricSpringNode extends Node {

// Changes to these properties can be accomplished by mutating existing points (Vector2) and Shapes,
// because the number of points remains the same, as does their allocation to frontShape and backShape.
Property.lazyMultilink(
Multilink.lazyMultilink(
[ this.radiusProperty, this.xScaleProperty ],
( radius, xScale ) => {

Expand Down Expand Up @@ -269,7 +269,7 @@ class ParametricSpringNode extends Node {
} );

// Update the stroke gradients
Property.multilink(
Multilink.multilink(
[ this.radiusProperty, this.aspectRatioProperty ],
( radius, aspectRatio ) => {

Expand Down
4 changes: 2 additions & 2 deletions js/SegmentedBarGraphNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import Range from '../../dot/js/Range.js';
import Property from '../../axon/js/Property.js';
import Multilink from '../../axon/js/Multilink.js';
import InstanceRegistry from '../../phet-core/js/documentation/InstanceRegistry.js';
import optionize from '../../phet-core/js/optionize.js';
import { IColor, Node, NodeOptions, Rectangle } from '../../scenery/js/imports.js';
Expand Down Expand Up @@ -82,7 +82,7 @@ export default class SegmentedBarGraphNode extends Node {
} );

// set the visibility and opacity of each of the segments based on the value and range
Property.multilink( [ numberProperty, rangeProperty ], ( value, range ) => {
Multilink.multilink( [ numberProperty, rangeProperty ], ( value, range ) => {
assert && assert( range.min <= value && value <= range.max,
`numberProperty is out of range: ${value}` );

Expand Down
5 changes: 2 additions & 3 deletions js/WireNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
*/

import IReadOnlyProperty from '../../axon/js/IReadOnlyProperty.js';
import { UnknownMultilink } from '../../axon/js/Multilink.js';
import Property from '../../axon/js/Property.js';
import Multilink, { UnknownMultilink } from '../../axon/js/Multilink.js';
import Vector2 from '../../dot/js/Vector2.js';
import { Shape } from '../../kite/js/imports.js';
import optionize from '../../phet-core/js/optionize.js';
Expand Down Expand Up @@ -38,7 +37,7 @@ export default class WireNode extends Path {

super( null, options );

this.multilink = Property.multilink( [
this.multilink = Multilink.multilink( [
position1Property, normal1Property, position2Property, normal2Property
], ( position1, normal1, position2, normal2 ) => {
this.shape = new Shape()
Expand Down
4 changes: 2 additions & 2 deletions js/capacitor/CapacitorNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @author Andrew Adare (PhET Interactive Simulations)
*/

import Property from '../../../axon/js/Property.js';
import Multilink from '../../../axon/js/Multilink.js';
import validate from '../../../axon/js/validate.js';
import Bounds2 from '../../../dot/js/Bounds2.js';
import { Shape } from '../../../kite/js/imports.js';
Expand Down Expand Up @@ -58,7 +58,7 @@ class CapacitorNode extends Node {
this.addChild( eFieldNode );
this.addChild( this.topPlateNode );

const updateGeometry = Property.multilink( [
const updateGeometry = Multilink.multilink( [
this.capacitor.plateSizeProperty,
this.capacitor.plateSeparationProperty
], () => this.updateGeometry() );
Expand Down
4 changes: 2 additions & 2 deletions js/capacitor/EFieldNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


//modules
import Property from '../../../axon/js/Property.js';
import Multilink from '../../../axon/js/Multilink.js';
import Dimension2 from '../../../dot/js/Dimension2.js';
import EnumerationDeprecated from '../../../phet-core/js/EnumerationDeprecated.js';
import { CanvasNode } from '../../../scenery/js/imports.js';
Expand Down Expand Up @@ -85,7 +85,7 @@ class EFieldNode extends CanvasNode {
this.modelViewTransform = modelViewTransform;
this.maxEffectiveEField = maxEffectiveEField;

Property.multilink( [
Multilink.multilink( [
capacitor.plateSizeProperty,
capacitor.plateSeparationProperty,
capacitor.plateVoltageProperty
Expand Down
4 changes: 2 additions & 2 deletions js/capacitor/PlateChargeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @author Andrew Adare (PhET Interactive Simulations)
*/

import Property from '../../../axon/js/Property.js';
import Multilink from '../../../axon/js/Multilink.js';
import validate from '../../../axon/js/validate.js';
import Dimension2 from '../../../dot/js/Dimension2.js';
import Range from '../../../dot/js/Range.js';
Expand Down Expand Up @@ -77,7 +77,7 @@ class PlateChargeNode extends CanvasNode {
this.addChild( this.parentNode );

// No disposal required because the capacitor exists for the life of the sim
Property.multilink( [
Multilink.multilink( [
capacitor.plateSizeProperty,
capacitor.plateChargeProperty
], () => self.isVisible() && self.invalidatePaint()
Expand Down
5 changes: 3 additions & 2 deletions js/demo/ComponentsScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/

import BooleanProperty from '../../../axon/js/BooleanProperty.js';
import Multilink from '../../../axon/js/Multilink.js';
import DerivedProperty from '../../../axon/js/DerivedProperty.js';
import Emitter from '../../../axon/js/Emitter.js';
import EnumerationProperty from '../../../axon/js/EnumerationProperty.js';
Expand Down Expand Up @@ -670,7 +671,7 @@ function demoProbeNode( layoutBounds ) {
const redProperty = new Property( color.red );
const greenProperty = new Property( color.green );
const blueProperty = new Property( color.blue );
Property.multilink( [ redProperty, greenProperty, blueProperty ],
Multilink.multilink( [ redProperty, greenProperty, blueProperty ],
( r, g, b ) => {
colorProperty.value = new Color( r, g, b );
} );
Expand All @@ -697,7 +698,7 @@ function demoProbeNode( layoutBounds ) {
demoParent.addChild( radioButtonGroup );

// When the model properties change, update the sensor node
Property.multilink( [
Multilink.multilink( [
colorProperty,
radiusProperty,
innerRadiusProperty,
Expand Down

0 comments on commit b4fc53a

Please sign in to comment.