CookieStoreManager: phương thức unsubscribe()
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Service Workers.
Phương thức unsubscribe() của giao diện CookieStoreManager ngừng để ServiceWorkerRegistration nhận các sự kiện đã đăng ký trước đó.
Cú pháp
js
unsubscribe(subscriptions)
Tham số
subscriptions-
Một danh sách đối tượng, mỗi đối tượng chứa:
Giá trị trả về
Một Promise được phân giải với undefined khi service worker đã được hủy đăng ký.
Ngoại lệ
Ví dụ
Trong ví dụ này, ServiceWorkerRegistration được biểu diễn bởi registration hủy đăng ký nhận các sự kiện thay đổi trên cookie có tên "cookie1" với phạm vi là "/path1".
js
const subscriptions = [{ name: "cookie1", url: `/path1` }];
await registration.cookies.unsubscribe(subscriptions);
Thông số kỹ thuật
| Specification |
|---|
| Cookie Store API> # dom-cookiestoremanager-unsubscribe> |