- if B was added after A, it will not receive the current event
- if A was added after B, then B has already received the event by the time it is removed.
If I encountered that during a code-review, I would be very suspicious.
The right thing to do here is probably the more simple thing that the AI also seems to be suggesting :
for (const listener of this.listeners) listener(arg);