SharedStorageWorkletGlobalScope

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Giao diện SharedStorageWorkletGlobalScope của Shared Storage API đại diện cho phạm vi toàn cục của module SharedStorageWorklet.

WorkletGlobalScope SharedStorageWorkletGlobalScope

Thuộc tính phiên bản

sharedStorage Deprecated

Chứa một thể hiện của đối tượng WorkletSharedStorage, đại diện cho bộ lưu trữ dùng chung cho một nguồn gốc cụ thể như được hiển thị trong ngữ cảnh worklet.

Phương thức phiên bản

register() Deprecated

Đăng ký một thao tác được định nghĩa bên trong module worklet hiện tại.

Ví dụ

js
// ab-testing-worklet.js
class SelectURLOperation {
  async run(urls, data) {
    // Đọc nhóm thử nghiệm của người dùng từ shared storage
    const experimentGroup = await this.sharedStorage.get("ab-testing-group");

    // Trả về số nhóm
    return experimentGroup;
  }
}

register("ab-testing", SelectURLOperation);

Xem trang đích Shared Storage API để xem hướng dẫn về ví dụ này và các liên kết đến các ví dụ khác.

Thông số kỹ thuật

Specification
Shared Storage API
# sharedstorageworkletglobalscope

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

Xem thêm