[CONTEXT]: provided values are handed over on connect only, consumers do not follow later provider updates

Đang mở
#175 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript
Lĩnh vực
frontend

Hướng nghiên cứu

Read BaseElement.update() and verifyProvidedProperties() to assess the proposed update hook and its subtree walk; compare the behavior with the context example in examples/showcase/ and the current context documentation. The issue needs a maintainer decision between documenting connect-time values and updating consumers after provider changes; done means that decision is reflected consistently in the implementation or docs, showcase, and treatment of manual requestContext() callbacks.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

question

Observation

A provider lists a plain value in provideProperties():

class Provider extends TemplateElement {
    properties() {
        return { theme: 'light' };
    }
    provideProperties() {
        return { theme: this.theme };
    }
}

class Consumer extends TemplateElement {
    injectProperties() {
        return { theme: '' };
    }
}

The consumer gets light when it connects. When the provider sets this.theme = 'dark' later, the consumer keeps light. A Store in provideProperties() behaves differently: it is handed over by reference, the consumer subscribes to it, so changes in the store render the consumer.

The context section of examples/showcase/ (#171) shows both behaviours side by side.

Cause

verifyProvidedProperties() replays missed requests and compares customChild[key] !== providedProperties[key], but it only runs in connectedCallback() (both branches). Nothing runs it after a provider update.

Options

  1. Document it: a provided value is handed over when the consumer connects, values that change are provided as a Store. No code.
  2. Run this.verifyProvidedProperties() at the end of BaseElement.update(). Three lines, consumers then follow every provided value. Costs a subtree walk (getAllComposedElementChildren) on every render of an element that provides something, and manual requestContext() callbacks still fire once only, which should be stated either way.

The docs currently say the injected value "will be just there at some point", which does not decide this. A maintainer decision, the showcase and the docs follow it.

Ngôn ngữ chính
JavaScript
Star
30
Fork
5
Merge trung bình
1 giờ 57 phút
Pull request đã merge (30 ngày)
10

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của webtides/element-js

Tất cả issue của webtides/element-js

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.