Skip to content

Commit

Permalink
Specify isDisposable false, see: #258
Browse files Browse the repository at this point in the history
  • Loading branch information
marlitas committed Jun 3, 2024
1 parent 90e3bd8 commit fc30f50
Show file tree
Hide file tree
Showing 37 changed files with 94 additions and 43 deletions.
1 change: 1 addition & 0 deletions js/balance-point/model/BalancePointModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default class BalancePointModel extends SoccerModel<BalancePointSceneMode
}
);
},
isDisposable: false,
phetioState: false
}, providedOptions );

Expand Down
7 changes: 6 additions & 1 deletion js/balance-point/model/BalancePointSceneModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import NumberIO from '../../../../tandem/js/types/NumberIO.js';
import LinearFunction from '../../../../dot/js/LinearFunction.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import BalancePointModel from './BalancePointModel.js';
import optionize, { EmptySelfOptions } from '../../../../phet-core/js/optionize.js';

type BalancePointSceneModelOptions = SoccerSceneModelOptions;

Expand Down Expand Up @@ -61,7 +62,11 @@ export default class BalancePointSceneModel extends SoccerSceneModel {

public constructor( isMeanFulcrumFixedProperty: BooleanProperty,
maxKicksProperty: Property<number>,
options: BalancePointSceneModelOptions ) {
providedOptions: BalancePointSceneModelOptions ) {

const options = optionize<BalancePointSceneModelOptions, EmptySelfOptions, SoccerSceneModelOptions>()( {
isDisposable: false
}, providedOptions );

const kickDistributionStrategy = new KickDistributionStrategy(
'randomSkew',
Expand Down
3 changes: 2 additions & 1 deletion js/balance-point/view/BalanceBeamNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ export default class BalanceBeamNode extends Node {
) {

const options = optionize<BalanceBeamNodeOptions, EmptySelfOptions, NodeOptions>()( {
phetioVisiblePropertyInstrumented: false
phetioVisiblePropertyInstrumented: false,
isDisposable: false
}, providedOptions );

const notepadNumberLineNode = new NumberLineNode(
Expand Down
3 changes: 2 additions & 1 deletion js/balance-point/view/FixedFulcrumIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export default class FixedFulcrumIcon extends Node {
const iconDimension = icon.width > icon.height ? icon.width : icon.height;
const superOptions = combineOptions<NodeOptions>( {
children: [ icon ],
localBounds: new Bounds2( 0, 0, iconDimension, iconDimension )
localBounds: new Bounds2( 0, 0, iconDimension, iconDimension ),
isDisposable: false
}, options );
super( superOptions );
icon.center = this.center;
Expand Down
3 changes: 2 additions & 1 deletion js/balance-point/view/MeanPredictionFulcrumSlider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export default class MeanPredictionFulcrumSlider extends HSlider {
// Necessary to remove rounding errors and apply the constrainValue option during shift steps. https://github.com/phetsims/sun/issues/837
a11yMapValue: value => Utils.roundToInterval( value, MeanShareAndBalanceConstants.MEAN_ROUNDING_INTERVAL ),
trackSize: new Dimension2( MeanShareAndBalanceConstants.CHART_VIEW_WIDTH, 0 ),
drag: () => { fulcrumWasDraggedProperty.value = true; }
drag: () => { fulcrumWasDraggedProperty.value = true; },
isDisposable: false
}, providedOptions );
super( fulcrumValueProperty, MeanShareAndBalanceConstants.SOCCER_BALL_RANGE, options );

Expand Down
3 changes: 2 additions & 1 deletion js/balance-point/view/MovableFulcrumIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export default class MovableFulcrumIcon extends Node {
const iconDimension = icon.width > icon.height ? icon.width : icon.height;
const superOptions = combineOptions<NodeOptions>( {
children: [ icon ],
localBounds: new Bounds2( 0, 0, iconDimension, iconDimension )
localBounds: new Bounds2( 0, 0, iconDimension, iconDimension ),
isDisposable: false
}, options );
super( superOptions );
icon.center = this.center;
Expand Down
3 changes: 2 additions & 1 deletion js/common/model/Plate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ export default class Plate<T extends Snack> extends PhetioObject {
phetioState: false,
startingNumberOfSnacks: 1,
snackStackingFunction: SnackStacker.getStackedCandyBarPosition,
handleFraction: _.noop // By default plates _.noop snack fraction values.
handleFraction: _.noop, // By default plates _.noop snack fraction values.
isDisposable: false
}, providedOptions );

super( options );
Expand Down
1 change: 1 addition & 0 deletions js/common/model/SharingModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default class SharingModel<T extends Snack> extends PhetioObject implemen
providedOptions: SharingModelOptions ) {

const options = optionize<SharingModelOptions, SelfOptions, PhetioObjectOptions>()( {
isDisposable: false,
phetioType: SharingModel.SharingModelIO,
phetioState: false,
phetioDocumentation: 'The model for the Distribute and Fair Share screens, which includes tablePlates and notepadPlates.'
Expand Down
1 change: 1 addition & 0 deletions js/common/model/Snack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default class Snack extends PhetioObject {
const options = optionize<SnackOptions, SelfOptions, PhetioObjectOptions>()( {
initiallyActive: false,
initialPosition: Vector2.ZERO,
isDisposable: false,
phetioState: false
}, providedOptions );

Expand Down
3 changes: 2 additions & 1 deletion js/common/view/InfoBooleanStickyToggleButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export default class InfoBooleanStickyToggleButton extends BooleanRoundStickyTog
const options = combineOptions<BooleanRoundStickyToggleButtonOptions>( {
content: infoIcon,
baseColor: 'rgb( 238, 238, 238 )',
radius: 18
radius: 18,
isDisposable: false
}, providedOptions );

super( dialogVisibleProperty, options );
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/LabTableNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export default class LabTableNode extends Node {
} );

const options = optionize<TableNodeOptions, SelfOptions, NodeOptions>()( {
children: [ tableBottom, table ]
children: [ tableBottom, table ],
isDisposable: false
}, providedOptions );

super( options );
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/MeanCalculationPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ export default class MeanCalculationPanel extends Panel {
visibleProperty: visibleProperty,
resize: false,
calculatedMeanDisplayMode: 'decimal',
zeroDataMessageProperty: null
zeroDataMessageProperty: null,
isDisposable: false
}, providedOptions );

const calculationsVisibleProperty = DerivedProperty.deriveAny( [ ...calculationDependencies ], () => {
Expand Down
10 changes: 6 additions & 4 deletions js/common/view/MeanPredictionSlider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import meanShareAndBalance from '../../meanShareAndBalance.js';
import Vector2Property from '../../../../dot/js/Vector2Property.js';
import ModelViewTransform2 from '../../../../phetcommon/js/view/ModelViewTransform2.js';
import Range from '../../../../dot/js/Range.js';
import { combineOptions, EmptySelfOptions } from '../../../../phet-core/js/optionize.js';
import optionize, { combineOptions, EmptySelfOptions } from '../../../../phet-core/js/optionize.js';
import MeanShareAndBalanceConstants from '../MeanShareAndBalanceConstants.js';
import AccessibleSlider, { AccessibleSliderOptions } from '../../../../sun/js/accessibility/AccessibleSlider.js';
import Vector2 from '../../../../dot/js/Vector2.js';
Expand All @@ -28,7 +28,7 @@ import soundManager from '../../../../tambo/js/soundManager.js';

type SelfOptions = EmptySelfOptions;
type ParentOptions = AccessibleSliderOptions & NodeOptions;
type PredictMeanNodeOptions =
type MeanPredictionSliderOptions =
SelfOptions
& StrictOmit<ParentOptions, 'pickable' | 'inputEnabled' | 'focusable' | 'cursor' | 'children'>
& PickRequired<ParentOptions, 'tandem'>;
Expand All @@ -44,9 +44,11 @@ export default class MeanPredictionSlider extends AccessibleSlider( Node, 0 ) {
public constructor( meanPredictionProperty: Property<number>, dragRange: Range,
createSuccessIndicatorMultilink: ( predictMeanLine: Path, successRectangle: Node ) => void,
modelViewTransform: ModelViewTransform2,
providedOptions: PredictMeanNodeOptions ) {
providedOptions: MeanPredictionSliderOptions ) {

const options = providedOptions;
const options = optionize<MeanPredictionSliderOptions, SelfOptions, ParentOptions>()( {
isDisposable: false
}, providedOptions );

const predictMeanLine = new Line( new Vector2( 0, 0 ), new Vector2( MeanShareAndBalanceConstants.CUP_WIDTH, 0 ), {
lineWidth: MeanShareAndBalanceConstants.NOTEPAD_LINE_PATTERN_WIDTH,
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/MeanShareAndBalanceCheckboxGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default class MeanShareAndBalanceCheckboxGroup extends VerticalCheckboxGr
tickMarksVisibleProperty: null,
checkboxOptions: MeanShareAndBalanceConstants.CHECKBOX_OPTIONS,
align: 'left',
layoutOptions: { align: 'left' }
layoutOptions: { align: 'left' },
isDisposable: false
}, providedOptions );

const checkboxItems: VerticalCheckboxGroupItem[] = [];
Expand Down
8 changes: 6 additions & 2 deletions js/common/view/MeanShareAndBalanceControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,17 @@ export default class MeanShareAndBalanceControls extends Node {

const options = optionize<MeanShareAndBalanceControlsOptions, SelfOptions, NodeOptions>()( {
soccerContext: false,
infoPanelVisibleProperty: null
infoPanelVisibleProperty: null,
isDisposable: false
}, providedOptions );
const controlsAlignGroup = new AlignGroup( { matchVertical: false } );

const vBoxAlignBox = controlsAlignGroup.createBox( controlsVBox, { xAlign: 'left' } );

super( { children: [ vBoxAlignBox ] } );
const superOptions = combineOptions<NodeOptions>( {
children: [ vBoxAlignBox ]
}, options );
super( superOptions );

if ( options.infoPanelVisibleProperty ) {

Expand Down
3 changes: 2 additions & 1 deletion js/common/view/NotepadNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export default class NotepadNode extends Node {
const options = optionize<NotepadNodeOptions, SelfOptions, NodeOptions>()( {
readoutPatternStringProperty: null,
totalVisibleProperty: null,
phetioVisiblePropertyInstrumented: false
phetioVisiblePropertyInstrumented: false,
isDisposable: false
}, providedOptions );

const paperStackNode = new Node();
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/NumberSpinnerVBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export default class NumberSpinnerVBox extends VBox {
providedOptions: NumberSpinnerVBoxOptions ) {

const options = optionize<NumberSpinnerVBoxOptions, SelfOptions, VBoxOptions>()( {
minContentHeight: 100
minContentHeight: 100,
isDisposable: false
}, providedOptions );

const numberOfCupsText = new Text( stringProperty, {
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/PartyTableNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export default class PartyTableNode extends Image {
public constructor( providedOptions?: PartyTableNodeOptions ) {

const options = optionize<PartyTableNodeOptions, SelfOptions, NodeOptions>()( {
maxWidth: 780 // width empirically determined to work with the plate placements
maxWidth: 780, // width empirically determined to work with the plate placements
isDisposable: false
},
providedOptions
);
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/SyncButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export default class SyncButton extends RectangularPushButton {
const options = optionize<SyncButtonOptions, SelfOptions, RectangularPushButtonOptions>()( {
content: syncContent,
baseColor: 'white',
accessibleName: MeanShareAndBalanceStrings.syncStringProperty
accessibleName: MeanShareAndBalanceStrings.syncStringProperty,
isDisposable: false
}, providedOptions );

super( options );
Expand Down
2 changes: 1 addition & 1 deletion js/common/view/SyncIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class SyncIcon extends Node {
const downArrow = new LineArrowNode( 0, 0, 0, ARROW_LENGTH, arrowOptions );
const upArrow = new LineArrowNode( ARROW_SPACING, ARROW_LENGTH, ARROW_SPACING, 0, arrowOptions );

super( { children: [ downArrow, upArrow ], scale: 0.5 } );
super( { children: [ downArrow, upArrow ], scale: 0.5, isDisposable: false } );
}
}
meanShareAndBalance.register( 'SyncIcon', SyncIcon );
3 changes: 2 additions & 1 deletion js/common/view/TablePlateNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export default class TablePlateNode<T extends Snack> extends Node {
const options = optionize<PersonNodeOptions, SelfOptions, NodeOptions>()( {
snackQuantitySoundPlayerOptions: {
initialOutputLevel: 0.2
}
},
isDisposable: false
}, providedOptions );

const plateImage = new Image( plate_svg, {
Expand Down
3 changes: 2 additions & 1 deletion js/distribute/view/DistributeNotepadPlateNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export default class DistributeNotepadPlateNode extends Node {
const options = optionize<NotepadPlateNodeOptions, EmptySelfOptions, NodeOptions>()( {
visibleProperty: plate.isActiveProperty,
excludeInvisibleChildrenFromBounds: false,
children: [ plateNode ]
children: [ plateNode ],
isDisposable: false
}, providedOptions );

super( options );
Expand Down
3 changes: 2 additions & 1 deletion js/distribute/view/NotepadCandyBarNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export default class NotepadCandyBarNode extends InteractiveHighlighting( Node )

const options = optionize<NotepadCandyBarNodeOptions, SelfOptions, NodeOptions>()( {
children: children,
cursor: 'pointer'
cursor: 'pointer',
isDisposable: false
}, providedOptions );

super( options );
Expand Down
3 changes: 2 additions & 1 deletion js/distribute/view/PersonImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export default class PersonImage<T extends Snack> extends Image {
const options = optionize<PersonImageOptions, SelfOptions, ImageOptions>()( {
maxWidth: MAX_IMAGE_WIDTH,
centerX: tablePlateNode.centerX,
bottom: MeanShareAndBalanceConstants.PARTY_TABLE_Y + 95
bottom: MeanShareAndBalanceConstants.PARTY_TABLE_Y + 95,
isDisposable: false
}, providedOptions );

super( image, options );
Expand Down
3 changes: 2 additions & 1 deletion js/fair-share/view/FairShareNotepadPlateNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export default class FairShareNotepadPlateNode extends Image {

super( notepadPlateSketch_svg, {
maxWidth: MeanShareAndBalanceConstants.NOTEPAD_PLATE_DIMENSION.width,
visibleProperty: plateVisibleProperty
visibleProperty: plateVisibleProperty,
isDisposable: false
} );

// Set the Y position once. It shouldn't change after construction.
Expand Down
2 changes: 1 addition & 1 deletion js/fair-share/view/NotepadAppleNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class NotepadAppleNode extends Node {

// Layer the component Nodes together into the composite Node.
const options = optionize<NotepadAppleNodeOptions, SelfOptions, PathOptions>()(
{ children: [ backgroundNode, outlineCircle, foregroundShape ] },
{ children: [ backgroundNode, outlineCircle, foregroundShape ], isDisposable: false },
providedOptions
);

Expand Down
5 changes: 5 additions & 0 deletions js/level-out/model/Cup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import BooleanProperty from '../../../../axon/js/BooleanProperty.js';
import meanShareAndBalance from '../../meanShareAndBalance.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import Disposable from '../../../../axon/js/Disposable.js';

type SelfOptions = {
position: Vector2; // the cups x & y position in the view
Expand Down Expand Up @@ -91,6 +92,10 @@ export default class Cup {
this.partialReset();
this.isActiveProperty.reset();
}

public dispose(): void {
Disposable.assertNotDisposable();
}
}

meanShareAndBalance.register( 'Cup', Cup );
3 changes: 2 additions & 1 deletion js/level-out/model/LevelOutModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export default class LevelOutModel extends PhetioObject implements TModel {
const options = optionize<LevelOutModelOptions, EmptySelfOptions, PhetioObjectOptions>()( {
phetioType: LevelOutModel.LevelOutModelIO,
phetioState: false,
phetioDocumentation: 'The model for the LevelOut screen, which includes tableCups and notepadCups.'
phetioDocumentation: 'The model for the LevelOut screen, which includes tableCups and notepadCups.',
isDisposable: false
}, providedOptions );

super( options );
Expand Down
4 changes: 4 additions & 0 deletions js/level-out/model/Pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import optionize from '../../../../phet-core/js/optionize.js';
import PickRequired from '../../../../phet-core/js/types/PickRequired.js';
import { PhetioObjectOptions } from '../../../../tandem/js/PhetioObject.js';
import meanShareAndBalance from '../../meanShareAndBalance.js';
import Disposable from '../../../../axon/js/Disposable.js';

type SelfOptions = {
position: Vector2; // the x & y-position of the pipe in the view
Expand Down Expand Up @@ -70,6 +71,9 @@ export default class Pipe {
this.rotationProperty.value = rotationThreshold <= dt ? targetRotation : proposedRotation;
}

public dispose(): void {
Disposable.assertNotDisposable();
}
}


Expand Down
5 changes: 2 additions & 3 deletions js/level-out/view/LevelOutScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,8 @@ export default class LevelOutScreenView extends MeanShareAndBalanceScreenView {

// Add all cup nodes to the view.
const notepadCupNodes: Array<NotepadCupNode> = [];
model.notepadCups.forEach( ( cupModel, index ) => {
const cupNode = new NotepadCupNode( cupModel, model.tableCups[ index ], modelViewTransformNotepadCups,
model.meanProperty, model.tickMarksVisibleProperty,
model.notepadCups.forEach( cupModel => {
const cupNode = new NotepadCupNode( cupModel, modelViewTransformNotepadCups, model.tickMarksVisibleProperty,
{ tandem: notepadCupsParentTandem.createTandem( `notepadCupNode${cupModel.linePlacement + 1}` ) } );
notepadCupNodes.push( cupNode );
} );
Expand Down
6 changes: 3 additions & 3 deletions js/level-out/view/NotepadCupNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import NotepadCupTickMarksNode from './NotepadCupTickMarksNode.js';
import ModelViewTransform2 from '../../../../phetcommon/js/view/ModelViewTransform2.js';
import MeanShareAndBalanceConstants from '../../common/MeanShareAndBalanceConstants.js';
import MeanShareAndBalanceColors from '../../common/MeanShareAndBalanceColors.js';
import TReadOnlyProperty from '../../../../axon/js/TReadOnlyProperty.js';
import StrictOmit from '../../../../phet-core/js/types/StrictOmit.js';
import Property from '../../../../axon/js/Property.js';
import graphiteTexture_png from '../../../images/graphiteTexture_png.js';
Expand All @@ -28,12 +27,13 @@ type NotepadCupNodeOptions = SelfOptions & StrictOmit<NodeOptions, keyof NodeTra

export default class NotepadCupNode extends Node {

public constructor( notepadCup: Cup, tableCup: Cup, modelViewTransform: ModelViewTransform2, meanProperty: TReadOnlyProperty<number>,
public constructor( notepadCup: Cup, modelViewTransform: ModelViewTransform2,
showingTickMarksProperty: Property<boolean>, providedOptions?: NotepadCupNodeOptions ) {
const options = optionize<NotepadCupNodeOptions, SelfOptions, NodeOptions>()( {
y: modelViewTransform.modelToViewY( 0 ) - MeanShareAndBalanceConstants.CUP_HEIGHT,
left: notepadCup.position.x,
visibleProperty: notepadCup.isActiveProperty
visibleProperty: notepadCup.isActiveProperty,
isDisposable: false
}, providedOptions );

const tickMarks = new NotepadCupTickMarksNode(
Expand Down
Loading

0 comments on commit fc30f50

Please sign in to comment.