Is your feature request related to a problem? Please describe.
When trying to mimic browser APIs surrounding EventTarget, we frequently use CustomEvent which is currently unavailable in Node.
It's useful in that it allows us to dispatch events through an EventTarget and include a custom data payload.
In a some way, this is the closest we have to a standardised Observable API (specifically Subject) and it's very useful.
Describe the solution you'd like
CustomEvent exists
Describe alternatives you've considered
Writing a polyfill
class CustomEvent extends Event {
constructor(message, data) {
super(message, data)
this.detail = data.detail
}
}
const et = new EventTarget()
et.addEventListener('message', ev => console.log(ev.detail))
et.dispatchEvent(new CustomEvent('message', { detail: 'foo' }))
Is your feature request related to a problem? Please describe.
When trying to mimic browser APIs surrounding
EventTarget, we frequently useCustomEventwhich is currently unavailable in Node.It's useful in that it allows us to dispatch events through an
EventTargetand include a custom data payload.In a some way, this is the closest we have to a standardised
ObservableAPI (specificallySubject) and it's very useful.Describe the solution you'd like
CustomEventexistsDescribe alternatives you've considered
Writing a polyfill