Skip to content

[BUG] accumulation of addEventListener callbacks when using fast-reload #163

@adrian-kaehler

Description

@adrian-kaehler

Describe the bug
When Metro executes a fast-reload, the event listeners are not cleared, but the unregister functions are lost. As a result, every reload creates potentially more and more copies of the callbacks.

To Reproduce
Steps to reproduce the behavior:
Any structure that calls SoundPlayer.addEventListener and stores the unregister function. Change your code, save it. If you are using Metro, it will execute a fast-reload, which will reload the code, clearing your saved unregister functions.

Expected behavior
The behavior is expected, the API is not as needed or expected (more in "Additional Context" below).

Platform (please complete the following information):
In my case, I am developing using Android Studio on Windows 11. I do not expect this behavior to be different in any other environment where Metro is being used.

Additional context
The problem here is not one where the observed behavior is unexpected. The problem, at least as I understand it, is that there is no manual way to clear those callbacks. Compare to, for example, react-native-voice, which has the same issue, but provides a function removeAllCallbacks, that can be used to remove callbacks whose unregister functions are not know, lost, etc. It would seem that react-native-sound-player simply needs such a function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions