← Web Bluetooth: Make BluetoothRemoteGATTServer an EventTarget

v157 · enabled by default · inherited method

BluetoothRemoteGATTServer.removeEventListener()

Unregisters a listener that was added to a BluetoothRemoteGATTServer with addEventListener(). The method is inherited unchanged from EventTarget. It became available on the server through Chromium CL 8363084 and Web Bluetooth PR #672. See the overview shipping note for which Chrome release contains it.

syntax

server.removeEventListener(type, callback)
server.removeEventListener(type, callback, options)
server.removeEventListener(type, callback, useCapture)

Declared in the DOM Standard as:

undefined removeEventListener(DOMString type, EventListener? callback, optional (EventListenerOptions or boolean) options = {});
Source: DOM §2.7 EventTarget IDL (verbatim); receiver per Web Bluetooth PR #672 IDL.

parameters

removeEventListener() finds the listener to remove by three values, which must all match the original registration:

ParameterTypeMeaning
typeDOMStringThe event type the listener was registered for, for example "maxwritewithoutresponsesizechanged".
callbackEventListener?The same function or object that was passed to addEventListener(). A new arrow function with the same body does not match.
options.captureboolean, default falseMust equal the capture value used when the listener was added. Only capture is part of the match; once, passive and signal are ignored here. A boolean argument is the same as { capture: bool }.
Source: DOM EventListenerOptions; DOM removeEventListener() steps.

return value

removeEventListener() returns undefined. If the server’s listener list has an entry with the same type, callback and capture, that entry is marked removed and dropped from the list. Otherwise nothing happens. Calling it for a listener that was never added, or was already removed, is a silent no-op.

Source: DOM “remove an event listener”.

exceptions

Source: DOM EventTarget IDL; Web IDL.

context

Available on any BluetoothRemoteGATTServer in a secure-context Window, connected or not. You get the receiver from device.gatt. No permission prompt or user gesture is involved.

Source: PR #672 IDL; Web Bluetooth gatt getter.

lifecycle

Source: DOM “remove an event listener”; DOM AddEventListenerOptions.signal.

examples

const server = device.gatt;

function onSizeChange() {
  console.log("max write size:", server.maxWriteWithoutResponseSize);
}

server.addEventListener("maxwritewithoutresponsesizechanged", onSizeChange);

// Later, when the transfer UI closes:
server.removeEventListener("maxwritewithoutresponsesizechanged", onSizeChange);

// This does NOT remove it, because the capture flag differs:
server.removeEventListener("maxwritewithoutresponsesizechanged", onSizeChange, true);
Source: written for this page against the DOM removeEventListener() and PR #672 IDL; not executed against real hardware.

browser compatibility

BrowserOn BluetoothRemoteGATTServerEventTarget.removeEventListener (BCD)
Chrome / Chrome AndroidListed for 157 (interim, ChromeStatus); code merged after the M159 branch point, so the first release is unknown1 (options object 49)
EdgeUnknown (not separately reported)12
FirefoxNo (no Web Bluetooth)1
SafariNo (no Web Bluetooth)1

BCD has no key for this inherited member on BluetoothRemoteGATTServer. The receiver column is interim data from ChromeStatus, and the method column is from BCD api/EventTarget.json (fetched 2026-11-15).

security and privacy

Taking a listener off the list changes no device state, sends no Bluetooth traffic and needs no permission. It reveals nothing beyond the prototype-chain change described on the overview.

Source: ChromeStatus API record (security risks).

see also