Skip to content

Commit

Permalink
factor out TANDEM_NAME_SUFFIX, phetsims/tandem#267
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jul 11, 2022
1 parent b08ba52 commit 0666913
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions js/AquaRadioButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export default class AquaRadioButton<T> extends Voicing( Node, 0 ) {

private readonly disposeAquaRadioButton: () => void;

public static DEFAULT_RADIUS = 7;
public static readonly DEFAULT_RADIUS = 7;

public static readonly TANDEM_NAME_SUFFIX = 'RadioButton';

/**
* @mixes {Voicing}
Expand Down Expand Up @@ -96,8 +98,8 @@ export default class AquaRadioButton<T> extends Voicing( Node, 0 ) {

}, providedOptions );

assert && assert( !options.tandem.supplied || options.tandem.name.endsWith( 'RadioButton' ),
`AquaRadioButton tandem.name must end with RadioButton: ${options.tandem.phetioID}` );
assert && assert( !options.tandem.supplied || options.tandem.name.endsWith( AquaRadioButton.TANDEM_NAME_SUFFIX ),
`AquaRadioButton tandem.name must end with ${AquaRadioButton.TANDEM_NAME_SUFFIX}: ${options.tandem.phetioID}` );

super();

Expand Down
6 changes: 4 additions & 2 deletions js/buttons/RectangularRadioButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export default class RectangularRadioButton<T> extends RectangularButton {

private readonly disposeRectangularRadioButton: () => void;

public static readonly TANDEM_NAME_SUFFIX = 'RadioButton';

/**
* @param property - axon Property that can take on a set of values, one for each radio button in the group
* @param value - value when this radio button is selected
Expand Down Expand Up @@ -113,8 +115,8 @@ export default class RectangularRadioButton<T> extends RectangularButton {
phetioReadOnly: PhetioObject.DEFAULT_OPTIONS.phetioReadOnly // to support properly passing this to children, see https://github.com/phetsims/tandem/issues/60
}, providedOptions );

assert && assert( !options.tandem.supplied || options.tandem.name.endsWith( 'RadioButton' ),
`RectangularRadioButton tandem.name must end with RadioButton: ${options.tandem.phetioID}` );
assert && assert( !options.tandem.supplied || options.tandem.name.endsWith( RectangularRadioButton.TANDEM_NAME_SUFFIX ),
`RectangularRadioButton tandem.name must end with ${RectangularRadioButton.TANDEM_NAME_SUFFIX}: ${options.tandem.phetioID}` );

// Note it shares a tandem with this, so the emitter will be instrumented as a child of the button
const buttonModel = new ButtonModel( {
Expand Down

0 comments on commit 0666913

Please sign in to comment.