-
Notifications
You must be signed in to change notification settings - Fork 308
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
feat(websocket): add ability to remove listener #2027
base: v2
Are you sure you want to change the base?
Conversation
Change listeners array to use a set instead, which prevents addition of duplicated listeners which could possibly lead to memory leaks.
Package Changes Through 5d6a22cThere are 2 changes which include websocket-js with minor, websocket with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
i agree that a way to remove listeners is needed (that's why i didn't close the issue) but i'm not a fan of the Set here (or how it was used). I can very much imagine that someone wants to register the same function twice for whatever reason. Buuuut i'm totally fine with doing it this way and waiting to see if anyone actually complains. Also, changing the return value is technically a breaking change but because it didn't return anything before and because this plugin doesn't have that many users i think we can get away with it. |
Yes, that's exactly what I thought 😅
Yeah but it doesn't make sense to do so because same function gets invoked multiple times which can cause weird behaviors. |
The ability to remove a listener is pretty important in my opinion. Otherwise, you'd have to close the socket but you might still need the connection for other purposes. I say let's proceed with these changes. @twlite do you think you can look at the merge conflicts? |
done |
Looks like we got an error saying |
yes. since 2.2.0 the rust and js package must have matching versions (added the workflow at the same time to train ourselves to remember that) |
Are we good to go @FabianLars ? I looked around the documentation but I couldn't find any details about the release schedule/mechanism. Will merging this PR automatically create a new version of the package on NPM? |
This pr changes listeners array to use a set instead, which prevents addition of duplicated listeners which could possibly lead to memory leaks.