From 06669137a9522cf009e11b6b3dd0af986d43dfbf Mon Sep 17 00:00:00 2001 From: pixelzoom Date: Mon, 11 Jul 2022 17:14:00 -0600 Subject: [PATCH] factor out TANDEM_NAME_SUFFIX, https://github.com/phetsims/tandem/issues/267 --- js/AquaRadioButton.ts | 8 +++++--- js/buttons/RectangularRadioButton.ts | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/js/AquaRadioButton.ts b/js/AquaRadioButton.ts index 137ceb98..b0819f15 100644 --- a/js/AquaRadioButton.ts +++ b/js/AquaRadioButton.ts @@ -52,7 +52,9 @@ export default class AquaRadioButton 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} @@ -96,8 +98,8 @@ export default class AquaRadioButton 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(); diff --git a/js/buttons/RectangularRadioButton.ts b/js/buttons/RectangularRadioButton.ts index de51f56a..39921042 100644 --- a/js/buttons/RectangularRadioButton.ts +++ b/js/buttons/RectangularRadioButton.ts @@ -70,6 +70,8 @@ export default class RectangularRadioButton 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 @@ -113,8 +115,8 @@ export default class RectangularRadioButton 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( {