Skip to content

Commit

Permalink
Bugfix multiple event listeners with the same name (#2165)
Browse files Browse the repository at this point in the history
* Bugfix multiple event listeners with the same name

* Changelog

* changelog
  • Loading branch information
filipzeta committed Nov 16, 2022
1 parent b107cbe commit 5c474c6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -34,6 +34,7 @@ The minor version will be incremented upon a breaking change and the patch versi
* lang: Fix parsing for bytes literals in the IDL. ([#2261](https://github.com/coral-xyz/anchor/pull/2261))
* lang: Fix IDL `seed` generation for byte string literals. ([#2125](https://github.com/coral-xyz/anchor/pull/2125))
* ts: Update seeds inference to allow nested user defined structs within the seeds ([#2198](https://github.com/coral-xyz/anchor/pull/2198))
* event: Fix multiple event listeners with the same name. ([#2165](https://github.com/coral-xyz/anchor/pull/2165))

## [0.25.0] - 2022-07-05

Expand Down
3 changes: 2 additions & 1 deletion ts/packages/anchor/src/program/event.ts
Expand Up @@ -78,7 +78,7 @@ export class EventManager {
this._listenerIdCount += 1;

// Store the listener into the event map.
if (!(eventName in this._eventCallbacks)) {
if (!this._eventListeners.has(eventName)) {
this._eventListeners.set(eventName, []);
}
this._eventListeners.set(
Expand Down Expand Up @@ -138,6 +138,7 @@ export class EventManager {
// Update both maps.
this._eventCallbacks.delete(listener);
listeners = listeners.filter((l) => l !== listener);
this._eventListeners.set(eventName, listeners);
if (listeners.length === 0) {
this._eventListeners.delete(eventName);
}
Expand Down

1 comment on commit 5c474c6

@vercel
Copy link

@vercel vercel bot commented on 5c474c6 Nov 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

anchor-docs – ./

anchor-lang.com
anchor-docs-git-master-200ms.vercel.app
anchor-docs-200ms.vercel.app
www.anchor-lang.com

Please sign in to comment.