phetsims / sun

User-interface components for PhET simulations, built on top of Scenery.
MIT License
4 stars 12 forks source link

Add onInputEmiter to ABSwitch and ToggleSwitch #839

Closed zepumph closed 1 year ago

zepumph commented 1 year ago

From https://github.com/phetsims/sun/issues/701, this is proving to be important work for number play work. We want speech on input, but not always from the Property change (https://github.com/phetsims/number-suite-common/issues/56 and https://github.com/phetsims/number-suite-common/issues/47).

In sun 701, we generally decided that having input-based "view output" (like sound/voicing).

zepumph commented 1 year ago

@chrisklus and I found here that sound and voicing had already been sprinkled in here, so factoring it out to use the same Emitter that we want to use publicly seems really nice and very reasonable. This pattern isn't too hard, and I look forward to being able to continue to propagate it across the project.

zepumph commented 1 year ago

Noting here that ABSwitch doesn't support voicing, but toggleSwitch does. @jessegreenberg, can you please glance at the commit. How does it look to you?

jessegreenberg commented 1 year ago

Looking good! I can see how this is useful. I couldn't find anything incorrect, and I considered potential for memory leaks but disposal looks good. I don't think this will impact the PhET-iO APIs because this Emitter is not instrumented. Back to you.