Skip to content

make global object an instance of EventTarget #45981

Closed as not planned
Closed as not planned
@jimmywarting

Description

@jimmywarting

What is the problem this feature will solve?

This sounds like a simple feature request. We already got EventTarget and Event. So my feature request is to have a globalThis.addEventListener. (along with remove & dispatch) added to the global scope (by extending EventTarget)

What is the feature you are proposing to solve the problem?

Deno, browser and web workers and even cloudflare workers already has a global event listener that can be used to listen to a variety of things.
It can be used for listening to eg PostMessage, network offline/online, background fetch, any kind of errors etc.

This is partly related to #43583
Having different code paths to solve the same things gets troublesome.

What alternatives have you considered?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions