Merge pull request #3885 from thelounge/xpaw/eventbus-multi-arg

Support multiple arguments in eventbus emit
This commit is contained in:
Pavel Djundik 2020-04-28 16:02:24 +03:00 committed by GitHub
commit 801c7a07c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,13 +36,13 @@ class EventBus {
* @param {String} type The event type to invoke.
* @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler.
*/
emit(type, evt) {
emit(type, ...evt) {
if (events.has(type)) {
events
.get(type)
.slice()
.map((handler) => {
handler(evt);
handler(...evt);
});
}
}