Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can SoundGenerator's dispose call soundManager.removeSoundGenerator? #192

Open
zepumph opened this issue Mar 22, 2024 · 0 comments
Open
Assignees

Comments

@zepumph
Copy link
Member

zepumph commented Mar 22, 2024

@AgustinVallejo and I are finding discrepancies about how it is best to dispose SoundGenerators (while working on phetsims/scenery-phet#849). Looking at usages of soundManager.removeSoundGenerator, most are calling dispose on the soundGenerator right there (and the others seem like they likely should be).

We were brainstorming a couple of more automated ways of handling this.

  • Perhaps like calling removeSoundGenerator (with grace) from the disposal of SoundGenerator automatically.
  • Or having addSoundGenerator hook into the disposal of the soundGenerator to auto remove (then that listener is removed if removeSoundGenerator is called without disposing).

I'd start by looking at the 17 usages of removeSoundGenerator() to see if this is really the pattern we want to propagate across the project. Can't the library support this internally?

@jbphet if you give me some direction I'm happy to take a look at implementing.

For example for our new RichKeyboardDragListener:

https://github.com/phetsims/scenery-phet/blob/355d4de45aeeecea3d0537b80af0adcccc848060/js/RichKeyboardDragListener.ts#L88-L99

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants