-
Notifications
You must be signed in to change notification settings - Fork 16
Support * event type for mapping/handling #9
Conversation
const globalMappers = this.mappers[globalEventType] || []; | ||
const globalHandlers = this.handlers[globalEventType] || []; | ||
const mappers = (this.mappers[type] || []).concat(globalMappers); | ||
const handlers = (this.handlers[type] || []).concat(globalHandlers); | ||
const event = { | ||
type, | ||
payload: mappers.reduce((payload, mapper) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we previously had an implicit wildcard match in getArgs
below, which mapped to all key-less types. Given this change, that would no longer be supported (a la 'all key-less types are handled together'). Is that something we wanted to support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the intended behavior of that was to have * behave as a wildcard. I don't think there is any value in supporting events with no type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Listening on * seems like it could be a footgun to me. If we're sure though...
I agree it may potentially be misleading for folks (Cool! I can wildcard anything... myPlugin::*).I do think the use-case itself seems reasonable. As an alternative, I could see expanding the surface area of the API with something like .onAny or .onGlobal |
It definitely is. tbh, I would consider having this be an undocumented feature. We are only adding it because we need it to accomplish something somewhat uber specific. |
!merge |
Fixes #10