PressureObserver: phương thức unobserve()

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Note: This feature is available in Web Workers, except for Service Workers.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Phương thức unobserve() của giao diện PressureObserver dừng hàm callback của pressure observer nhận bản ghi áp lực từ nguồn được chỉ định.

Cú pháp

js
unobserve(source)

Tham số

source

Một chuỗi chỉ định source nào cần dừng quan sát.

Giá trị trả về

Không có (undefined).

Ví dụ

Dừng quan sát một nguồn cụ thể

Ví dụ sau cho thấy cách dừng quan sát nguồn "gpu" sau khi observer trước đó đã quan sát cả hai nguồn "cpu" và "gpu".

js
const observer = new PressureObserver(callback);

observer.observe("cpu");
observer.observe("gpu");

// Callback now gets called whenever the pressure state changes for 'cpu' or 'gpu'.

observer.unobserve("gpu");

// Callback now only gets called whenever the pressure state changes for 'cpu'.

Thông số kỹ thuật

Specification
Compute Pressure Level 1
# the-unobserve-method

Tương thích trình duyệt