aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Miller <[email protected]>2017-12-06 22:04:52 -0500
committerJason Miller <[email protected]>2017-12-06 22:04:52 -0500
commitf38922aa9190c9126c8fdc3306b32bd2c248b77e (patch)
treed07fc9f92892676efae668e81345e27c150c9615
parentb7276db3981956a903f987d89b1bc23863b7c13b (diff)
Fixes #65 - handler removal during handler invocation (`.off()` during `.emit()`).
-rw-r--r--src/index.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/index.js b/src/index.js
index 4fbdb44..116b7d8 100644
--- a/src/index.js
+++ b/src/index.js
@@ -54,8 +54,8 @@ export default function mitt(all: EventHandlerMap) {
* @memberOf mitt
*/
emit(type: string, evt: any) {
- (all[type] || []).map((handler) => { handler(evt); });
- (all['*'] || []).map((handler) => { handler(type, evt); });
+ (all[type] || []).slice().map((handler) => { handler(evt); });
+ (all['*'] || []).slice().map((handler) => { handler(type, evt); });
}
};
}