Back to Content

ReportingObserver: disconnect() method

files/en-us/web/api/reportingobserver/disconnect/index.md

latest1.0 KB
Original Source

{{APIRef("Reporting API")}}{{AvailableInWorkers}}

The disconnect() method of the {{domxref("ReportingObserver")}} interface stops a reporting observer that had previously started observing from collecting reports.

After calling disconnect(), neither {{domxref("ReportingObserver.takeRecords()")}} nor the records parameter of the ReportingObserver() callback will return any reports. The associated observer will no longer be active.

Syntax

js-nolint
disconnect()

Parameters

None.

Return value

None ({{jsxref("undefined")}}).

Examples

js
const options = {
  types: ["deprecation"],
  buffered: true,
};

const observer = new ReportingObserver((reports, observer) => {
  reportBtn.onclick = () => displayReports(reports);
}, options);

observer.observe();

// …

observer.disconnect();

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also