StopwatchNode does not update immediately when associated StringProperties are changed.
Closed this issue · 2 comments
pixelzoom commented
Related to #780 ...
If the value formatter for StopwatchNode is created using StopwatchNode.createRichTextNumberFormatter
, the displayed value is not immediately updated when the associated StringProperties are changed. As noted in StopwatchNode.ts:
/**
* Creates a custom value for options.numberDisplayOptions.numberFormatter, passed to NumberDisplay.
*
* TODO https://github.com/phetsims/scenery-phet/issues/781
* Because this is called by NumberDisplay when its valueProperty changes, there's no way to make
* this API update immediately when options.valueUnitsPattern or options.units changes. The NumberDisplay
* will not show changes to those strings until the value changes. If this is a problem, we'll need to
* come up with a new API for updating the NumberDisplay when associated StringProperties change.
*/
public static createRichTextNumberFormatter( providedOptions?: FormatterOptions ): ( time: number ) => string {
pixelzoom commented
Where createRichTextNumberFormatter
is used, this should be addressed using strictAxonDependencies
. It's not ideal, but here's an example from WaveInterferenceStopwatchNode.ts:
numberFormatter: StopwatchNode.createRichTextNumberFormatter( {
showAsMinutesAndSeconds: false,
units: unitsProperty
} ),
numberFormatterDependencies: [
SceneryPhetStrings.stopwatchValueUnitsPatternStringProperty, // used by StopwatchNode.createRichTextNumberFormatter
unitsProperty
],
phet-dev commented
Reopening because there is a TODO marked for this issue.