Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lucky-stingrays-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"overlay-kit": patch
---

refactor: Replace map with forEach in event emitter
4 changes: 2 additions & 2 deletions packages/src/utils/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ export function createEmitter<Events extends Record<EventType, unknown>>(
emit<Key extends keyof Events>(type: Key, evt?: Events[Key]) {
let handlers = all!.get(type);
if (handlers) {
(handlers as EventHandlerList<Events[keyof Events]>).slice().map((handler) => {
(handlers as EventHandlerList<Events[keyof Events]>).slice().forEach((handler) => {
handler(evt!);
});
}

handlers = all!.get('*');
if (handlers) {
(handlers as WildCardEventHandlerList<Events>).slice().map((handler) => {
(handlers as WildCardEventHandlerList<Events>).slice().forEach((handler) => {
handler(type, evt!);
});
}
Expand Down