Skip to content

Fire connect and disconnect events on USBDevice and bubble #213

Open
@reillyeon

Description

@reillyeon

The connect and disconnect events are currently only fired on navigator.usb. For disconnects in particular it is useful to be able to listen for a particular device being disconnected. For the Web Serial API we did this by making SerialPort itself an EventTarget and defining a custom parent algorithm so that the events bubble to navigator.serial after being fired on the SerialPort.

We should do the same for this API. I believe such a change would be backwards compatible. The only difference is that the target attribute of the USBConnectionEvent would be set to the value of its device attribute instead of navigator.usb.

The current workaround developers have to employ is to register an event handler and compare it against the device they are interested in.

CC @RReverser

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions