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

EventEmitter#listeners & ScaleManager#listeners #6260

Closed
x-wk opened this issue Oct 20, 2022 · 2 comments
Closed

EventEmitter#listeners & ScaleManager#listeners #6260

x-wk opened this issue Oct 20, 2022 · 2 comments

Comments

@x-wk
Copy link

x-wk commented Oct 20, 2022

Version

  • Phaser Version:
    Phaser v3.60.0-beta.12 (WebGL | Web Audio)
  • Operating system:
    win10
  • Browser:
    Microsoft Edge 106.0.1370.34

Description

To avoid removing the event handler set by the system, so i remove the event listener according to the context object, but ScaleManager has a property names 'listeners', then:

TypeError: emitter.listeners is not a function

Do you think this is a problem that should be fixed?

Example Test Code

   protected removeListener$$(emitter: EventEmitter, eventName: string | symbol, context: any) {
      const count = emitter.listenerCount(eventName);
      if (count > 0) {
         const listeners = emitter.listeners(eventName);
         for (const fn of listeners) {
            emitter.removeListener(eventName, fn, context);
         }
      }
   }

Additional Information

@photonstorm
Copy link
Collaborator

Yes, I agree this is wrong. We should probably just rename the ScaleManager.listeners property to something else.

@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

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

No branches or pull requests

2 participants