-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Closed
Labels
eventtargetIssues and PRs related to the EventTarget implementation.Issues and PRs related to the EventTarget implementation.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.
Description
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' }))
regseb, davbrito, colxi, achingbrain, oytuntez and 11 moren1ru4ln1ru4l
Metadata
Metadata
Assignees
Labels
eventtargetIssues and PRs related to the EventTarget implementation.Issues and PRs related to the EventTarget implementation.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.