Skip to content

Commit f38922a

Browse files
committed
Fixes #65 - handler removal during handler invocation (.off() during .emit()).
1 parent b7276db commit f38922a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ export default function mitt(all: EventHandlerMap) {
5454
* @memberOf mitt
5555
*/
5656
emit(type: string, evt: any) {
57-
(all[type] || []).map((handler) => { handler(evt); });
58-
(all['*'] || []).map((handler) => { handler(type, evt); });
57+
(all[type] || []).slice().map((handler) => { handler(evt); });
58+
(all['*'] || []).slice().map((handler) => { handler(type, evt); });
5959
}
6060
};
6161
}

0 commit comments

Comments
 (0)